Thứ Năm, 19 tháng 9, 2013

animation marquee

I am working in android.. i want to move my text in animation.
this is the xml code which i am using:-
android:shareInterpolator="true">

 <translate android:fromXDelta="0%p" android:toXDelta="-80%p"

android:fromYDelta="0%p" android:toYDelta="0%p" 

android:duration="2000" />
    android:pivotX="-70%p" android:pivotY="10%p" android:duration="1000"

    android:startOffset="2000" />
android:fromXDelta="0%p" android:toXDelta="80%p"

android:fromYDelta="0%p" android:toYDelta="0%p" android:duration="2000"

android:startOffset="3000" />
Using above xml my TEXT is moving in this shape:- enter image description here
But i want to move my text into this following way:- enter image description here
means i want to move my text into Z format. please suggest me how should write xml code for this. You can provide me some links for this. if you can code this then this will be very great help for me.
Thank you in advance.
share|improve this question

2 Answers

the following works for me:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:shareInterpolator="true">
    <translate
        android:fromXDelta="0%" android:toXDelta="80%p"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="2000"/>
    <translate 
        android:fromXDelta="0%" android:toXDelta="-80%p"
        android:fromYDelta="0%p" android:toYDelta="80%p"
        android:duration="1000" android:startOffset="2000"/>
    <translate 
        android:fromXDelta="0%" android:toXDelta="80%p"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="2000" android:startOffset="3000"/>
</set>
share|improve this answer
Thank you Jave... – Pushpendra Kuntal Dec 7 '11 at 6:03
You are welcome. – Jave Dec 7 '11 at 9:21
@jave i need one help. how to change the image when load the second translate.? pls help me – Ganesh Apr 12 '12 at 5:09
you can do this by using following steps.
1.create a animation.xml
2.put this code in this animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator"
    android:shareInterpolator="true">
    <translate
        android:fromXDelta="0%" android:toXDelta="80%p"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="2000"/>
    <translate 
        android:fromXDelta="0%" android:toXDelta="-80%p"
        android:fromYDelta="0%p" android:toYDelta="80%p"
        android:duration="1000" android:startOffset="2000"/>
    <translate 
        android:fromXDelta="0%" android:toXDelta="80%p"
        android:fromYDelta="0%" android:toYDelta="0%"
        android:duration="2000" android:startOffset="3000"/>
</set>
put this file into res/anim folder of your application.
write following code for your textview on which you want to make animation.
        Animation animation = AnimationUtils.loadAnimation(this,R.anim.animation);

        animation.setAnimationListener(this);

        View animatedView = findViewById(R.id.textview);

          animatedView.startAnimation(animation);

Không có nhận xét nào:

Đăng nhận xét