2011-11-29 41 views
6

我試圖讓文本從屏幕左側進入,當它到達其位置時,我希望文本可以向TextView的右側縮放。 這是動畫文件。如何將動畫android文本視圖縮放到右側

<?xml version="1.0" encoding="utf-8"?> 
<set 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- This is where the view moves onto the screen --> 
<translate 
android:fromXDelta="-200%" 
android:toXDelta="0%" 
android:fromYDelta="0%" 
android:toYDelta="0%" 
android:duration="1000" 
android:zAdjustment="top" ></translate> 
<!-- this is where I am scaling the text it currently aligns on the left side of the textview --> 
<scale 
android:fromXScale="1.0" 
android:fromYScale="1.0" 
android:toXScale=".2" 
android:startOffset="500" 
android:toYScale="1.0" 
android:duration="1000"></scale> 
<!-- I am then trying to make the text bounce over the left side of the textview --> 
<scale 
android:fromXScale="1.0" 
android:fromYScale="1.0" 
android:toXScale="7.0" 
android:startOffset="1500" 
android:toYScale="1.0" 
android:duration="200"></scale> 
<!-- I am then resetting the text to its original size --> 
<scale 
android:fromXScale="1.4" 
android:fromYScale="1.0" 
android:toXScale="1.0" 
android:toYScale="1.0" 
android:startOffset="1700" 
android:duration="50"></scale> 
</set> 

我也是這樣做的,當文本從右側進來,並且工作正常。 這就是textViews是在佈局

<TextView android:textColor="@android:color/black" android:textSize="50dip" android:layout_marginTop="40dip" android:layout_width="wrap_content" android:gravity="right" android:id="@+id/btnN" android:text="@string/play" android:layout_height="wrap_content" android:layout_marginLeft="50dip"></TextView> 

    <TextView android:textColor="@android:color/black" android:layout_marginBottom="40dip" android:textSize="50dip" android:layout_width="wrap_content" android:gravity="right" android:id="@+id/btnO" android:text="@string/option" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginLeft="50dip"></TextView> 

    <TextView android:id="@+id/btnI" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/info" android:textColor="@android:color/black" android:layout_marginRight="50dip" android:layout_marginTop="40dip" android:textSize="50dip" android:layout_alignParentRight="true"></TextView> 

    <TextView android:id="@+id/btnE" android:layout_height="wrap_content" android:layout_width="wrap_content" android:textColor="@android:color/black" android:text="@string/exit" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="40dip" android:layout_marginRight="50dip" android:textSize="50dip"></TextView> 
</RelativeLayout> 
btnN and btnO are the ones I need to do this animation for 
+0

請提供一個問題。究竟哪些方法不起作用,它們如何正確工作? – Warpzit

+0

嘗試在您想要向右側縮放的文本中添加'android:gravity =「right」'。這將對齊視圖右側的文本。 – Russ

回答

0

保存在一個新的文件夾RES /動畫文件。

Animation animation = AnimationUtils.loadAnimation(this, R.anim.urAnimation); 
urTextView.setAnimation(animation); or urTextView.startAnimation(animation); 

如您所需。

0

設置android:pivotX="100%"在您的動畫XML文件中縮放。

而且在Java文件:

Animation anim = AnimationUtils.loadAnimation(context, R.anim.yourAnimation); 
yourTextView.startAnimation(anim); 
相關問題