gpt4 book ai didi

Android TextView 过渡

转载 作者:行者123 更新时间:2023-11-30 01:31:35 29 4
gpt4 key购买 nike

我是安卓开发的新手。我想创建一个带有两个 TextView 的启动画面。在此初始屏幕中,我想要两个转换

1) Text View 1 从顶部到中心的过渡2) text View 2 从底部到中心的过渡

两个转换应该同时执行

如何实现?

谢谢,

最佳答案

在您的动画文件夹名称 bottom_to_top.xml 中创建一个 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>

和你的oncreat你添加这个

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

以及从上到下的动画

在你的动画文件夹中创建一个名为 top_bottom.xmlxml 文件

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

放在java中

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

希望对你有帮助

关于Android TextView 过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35691188/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com