向下滑动显示TextView的动画

向下滑动显示TextView的动画

本文介绍了向下滑动显示TextView的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感兴趣的切换上我的Andr​​oid应用程序一个TextView的知名度添加动画。我想它不只是能见度设置为Visibility.GONE和Visibility.VISIBLE - 相反,我希望它有像幻灯片效果的jQuery。这是很容易实现的?

I am interested in adding an animation on toggling the visibility of a TextView in my android application. I would like it to not just set the Visibility to Visibility.GONE and Visibility.VISIBLE - instead I want it to have a jquery like slide effect. Is this easy to accomplish?

推荐答案

应该不难,只写了XML中的动画,并将其放置在RES /阿尼姆。我不熟悉你后确切的动画,但在幻灯片看起来是这样的:

Shouldn't be hard, just write up the animation in xml and place it under res/anim. I'm not familiar with the exact animation you're after, but a slide in looks something like this:

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

你把它放在这样的观点:

You set it on the view like this:

Animation anim = AnimationUtils.loadAnimation(this, R.anim.slide_in_top);
view.startAnimation(anim);

如果你确保你设置在XML中'fillAfter属性,你不需要担心设置能见度(只要你的动画改变方向的alpha)。

If you ensure you set the 'fillAfter' attribute in the xml, you won't need to worry about setting visibility (as long as your animation changes the alpha of course).

要滑出只是让另一个动画,做相反的。

To slide out just make another animation that does the opposite.

这篇关于向下滑动显示TextView的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 01:50