Android text view transition

喜欢而已 提交于 2019-12-02 04:08:24

Creat an xml file in your anim folder name bottom_to_top.xml

  <?xml version="1.0" encoding="utf-8"?>
        <set xmlns:android="http://schemas.android.com/apk/res/android">
            <translate
                android:duration="2000"
                android:fillAfter="true"
                android:fromYDelta="100%p"
                android:toYDelta="0%p" />
        </set>

and your oncreat you add this

        TextView textview= (TextView) findViewById(R.id.textview);
        Animation bottomToTop = AnimationUtils.loadAnimation(this, R.anim.bottom_to_top);
        textview.startAnimation(bottomToTop);

and from top to bottom animation

create an xml file by name top_bottom.xml in your anim folder

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="2000"
        android:fillAfter="true"
        android:fromYDelta="-100%p"
        android:toYDelta="0%p" />
</set>

and place in java

            TextView textview2= (TextView) findViewById(R.id.textview2);
            Animation topTobottom = AnimationUtils.loadAnimation(this, R.anim.top_bottom);
            textview2.startAnimation(topTobottom );

Hope this helps you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!