dha*_*001 5 animation android slide
我有兴趣在我的Android应用程序中添加一个动画来切换TextView的可见性.我希望它不仅可以将Visibility设置为Visibility.GONE和Visibility.VISIBLE - 相反,我希望它有像幻灯片效果一样的jquery.这很容易实现吗?
sea*_*ain 13
不应该很难,只需在xml中编写动画并将其放在res/anim下.我不熟悉你所追求的确切动画,但幻灯片看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:repeatCount="0" >
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="-100%"
android:toYDelta="0%" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
Run Code Online (Sandbox Code Playgroud)
你在这个视图上设置它:
Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_top);
view.startAnimation(anim);
Run Code Online (Sandbox Code Playgroud)
如果您确保在xml中设置'fillAfter'属性,则无需担心设置可见性(只要您的动画当然更改了alpha).
要滑出,只需制作另一个相反的动画.
| 归档时间: |
|
| 查看次数: |
9618 次 |
| 最近记录: |