2013-05-20 19 views
0

我有一個背景顏色的文本視圖。我想用動畫放大/投影整個視圖。我嘗試使用縮放動畫,只有文字變大。我希望整個視圖能夠放大。我應該使用哪種動畫來達到此目的?提供建議。爲整個文本視圖縮放動畫android

+0

可能是文本視圖的父視圖大小相同像文本視圖。然後,您的文本視圖會在父視圖中剪切,而您看不到放大。 – Capitan

回答

0

您可以插入相對佈局TextView的,設置相對佈局的id和做大規模動畫相對佈局....

2

你的TextView添加到一個相對layout.And動畫應用到佈局。

XML:

<RelativeLayout 
    android:layout_width="300dp" 
    android:id="@+id/mylayout" 
    android:layout_height="50dp" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="218dp" 
    android:background="#000" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="TextView" 
     android:textColor="#fff" /> 

</RelativeLayout> 

的Java:

ScaleAnimation animation = new ScaleAnimation(fromXscale, toXscale, fromYscale, toYscale, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5); 

RelativeLayout rl=(RelativeLayout)findViewById(R.id.mylayout); 

rl.startAnimation(animation); 
+0

謝謝你...會嘗試 – user1526671