2016-03-28 23 views
0

Ich habe ein Problem beim Hochskalieren von TextViews und Checkboxen in Samsung GT-N5110 Android Version 4.1.2 das folgende Bild erscheint nach der Skalierung der TextView gibt es Textansicht innerhalb ich möchte es skalieren ich habe versucht, die Skalierung Animation in Entwickleroptionen ohne Verwendung Ich habe auch versucht neonoldandroid.jar.ObjectAnimator pixlated TextView

enter image description here

hier ist mein Code in fargment:

@Nullable 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     view = inflater.inflate(R.layout.test, container, false); 
     linearLayout = (LinearLayout) view.findViewById(R.id.test); 
     textView = (AutoResizeTextView) view.findViewById(R.id.text); 
     return view; 
    } 


    @Override 
     public void onStart() { 
      super.onStart(); 
    ObjectAnimator.ofFloat(linearLayout , "scaleY", 500).setDuration(500).start(); 
     ObjectAnimator.ofFloat(linearLayout , "scaleX", 500).setDuration(500).start(); 
     } 

Layout:

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 


     <LinearLayout 
      android:id="@+id/test" 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:background="@drawable/prayer_background"> 

      <com.example.views.AutoResizeTextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center" 
       android:text="@string/aboutUs" 
       android:textSize="5sp" /> 

     </LinearLayout> 
    </LinearLayout> 

prayer_background:

<?xml version="1.0" encoding="utf-8"?> 

    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="oval"> 
     <corners android:radius="10dip" /> 
     <stroke 
      android:width="5dip" 
      android:color="@color/mainColor" /> 
     <solid android:color="@color/mainColor" /> 
    </shape> 

Update:

habe ich versuchen AutoResizeText und ScaleableTextView erwähnt here: ich folgendes Ergebnis: enter image description here

+0

Sie sollten Ihre quesition mehr sauber machen. –

+0

können Sie mir sagen, wie :) – Muhammad

+0

Was möchten Sie erreichen? –

Antwort

0
private int dp2px(float dp){ 
      return (int) (dp * activity.getResources().getDisplayMetrics().density + 0.5f); 
     } 
     private doScale(){ 
      final LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.test); 
      final TextView textView = (TextView) linearLayout.findViewById(R.id.tv_main); 
      final int oldSize = dp2px(30); 
      final float scale = 2f; 
      final float textSizeOld = textView.getTextSize(); 
      ValueAnimator valueAnimatorLarge = ValueAnimator.ofInt(1,100); 
      valueAnimatorLarge.setDuration(500); 
      valueAnimatorLarge.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 

       @Override 
       public void onAnimationUpdate(ValueAnimator animation) { 
        ViewGroup.LayoutParams layoutParams = linearLayout.getLayoutParams(); 
        float currentScale = (int)animation.getAnimatedValue()/100f; 
        layoutParams.width = (int) (scale*oldSize*currentScale); 
        layoutParams.height = layoutParams.width; 
        linearLayout.setLayoutParams(layoutParams); 
        textView.setTextSize(scale*textSizeOld*currentScale); 
       } 
      }); 
      valueAnimatorLarge.start(); 
     } 
+0

float currentScale = (int) animation.getAnimatedValue()/100f; Ausnahme von Float zu int – Muhammad

Verwandte Themen