如何在5秒内显示闪烁的textview,然后让它不可见?

时间:2018-02-21 10:03:15

标签: android

我希望我的TextView显示5秒钟,因此当文本显示为浮华时它也将不可见。 谢谢你的帮助

<TextView
    android:id="@+id/tv"
    android:layout_width="50dp"
    android:layout_height="45dp"
    android:layout_marginStart="4dp"
    android:textColor="#FE9A2E"
    android:textSize="18dp"
    android:text="Hello"
    android:textStyle="bold"
    app:layout_constraintStart_toStartOf="parent"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteY="16dp"
    android:layout_marginLeft="4dp" />

2 个答案:

答案 0 :(得分:1)

是的,可以使用动画

把它放在res / anim文件夹中

alpha_invisible.xml

select *
  from table1
 where dbms_lob.instr (t1, -- the blob
                   utl_raw.cast_to_raw ('foo'), -- the search string cast to raw
                   1, -- where to start. i.e. offset
                   1 -- Which occurrance i.e. 1=first
                    ) > 0 -- location of occurrence. Here I don't care.  Just find any
;

Java文件:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:fillEnabled="true" >

<alpha
    android:duration="1000"
    android:fromAlpha="1.0"
    android:toAlpha="0.0" />

答案 1 :(得分:0)

您可以使用Android的AlphaAnimation使视图隐藏,并在一段时间后逐渐淡出动画。

AlphaAnimation animation = new AlphaAnimation(1f, 0f);
animation.setStartOffset(5000);
animation.setDuration(1000);
animation.setFillAfter(true);
tv.startAnimation(animation);

有关AlphaAnimation的详细信息:https://developer.android.com/reference/android/view/animation/AlphaAnimation.html