2011-11-29 10 views
6

पर एंड्रॉइड टेक्स्ट व्यू को एनिमेट करने के लिए कैसे करें, मैं स्क्रीन के बाईं ओर से टेक्स्ट आने की कोशिश कर रहा हूं, और जब यह अपनी स्थिति में आता है तो मैं टेक्स्ट को टेक्स्ट व्यू के दाईं ओर स्केल करना चाहता हूं । यह एनीमेशन फ़ाइल है।सही

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

टेक्स्ट को उस एंड्रॉइड: गुरुत्वाकर्षण = "दाएं" जोड़ने का प्रयास करें जिसे आप दाईं ओर स्केल करना चाहते हैं। यह दृश्य के दाईं ओर पाठ को संरेखित करेगा। – Russ

उत्तर

0

सहेजें एक नया फ़ोल्डर रेस/anim में फ़ाइल में हैं।

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

जैसा कि आपको आवश्यकता है।

0

सेट android:pivotX="100%" आपकी एनीमेशन एक्सएमएल फ़ाइल में स्केल करने के लिए।

और जावा फ़ाइल में:

Animation anim = AnimationUtils.loadAnimation(context, R.anim.yourAnimation); 
yourTextView.startAnimation(anim);