2011-11-29 28 views
6

Tôi đang cố gắng nhập văn bản từ bên trái màn hình và khi nó đến vị trí của nó, tôi muốn văn bản mở rộng về phía bên phải của TextView . Đây là tệp hoạt ảnh.cách chia tỷ lệ chế độ xem văn bản android animate sang bên phải

<?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> 

Tôi cũng làm điều này khi văn bản đến từ bên phải và hoạt động tốt. Đây là nơi TextView là trong cách bố trí

<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

Vui lòng cung cấp một câu hỏi. Chính xác những gì không hoạt động và nó hoạt động như thế nào? – Warpzit

+0

Thử thêm 'android: gravity =" right "' vào văn bản mà bạn muốn mở rộng về phía bên phải. Điều này sẽ căn chỉnh văn bản ở phía bên tay phải của chế độ xem. – Russ

Trả lời

0

Lưu tập tin trong một thư mục res mới/anim.

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

Như bạn yêu cầu.

0

đặt android:pivotX="100%" để mở rộng trong tệp XML hoạt ảnh của bạn.

Và trong file java:

Animation anim = AnimationUtils.loadAnimation(context, R.anim.yourAnimation); 
yourTextView.startAnimation(anim); 
Các vấn đề liên quan