我一直試圖讓文本在Android小部件中設置動畫。具體來說,我希望文本淡入淡出。在Android小部件中設置動畫文本
我知道這是可能的,因爲與大多數Android手機一起提供的精靈新聞和天氣小工具可以實現這一點。但是,我不明白這是如何使用動畫製作器或文本切換器完成的(兩者似乎都不支持)。
我假設這不是使用警報完成的,因爲這看起來像是動畫的總體矯枉過正。
有誰知道如何做到這一點?
我一直試圖讓文本在Android小部件中設置動畫。具體來說,我希望文本淡入淡出。在Android小部件中設置動畫文本
我知道這是可能的,因爲與大多數Android手機一起提供的精靈新聞和天氣小工具可以實現這一點。但是,我不明白這是如何使用動畫製作器或文本切換器完成的(兩者似乎都不支持)。
我假設這不是使用警報完成的,因爲這看起來像是動畫的總體矯枉過正。
有誰知道如何做到這一點?
您可以使用奧飛動漫,在一個XML文件中定義或編程... 這裏是關於動畫的文檔: http://developer.android.com/guide/topics/resources/animation-resource.html#alpha-element
你想什麼時候動畫開始?
如果你調用的setText在textSwitcher將淡出目前的案文,並在新的文本褪色,您可以使用ViewSwitcher或TextSwitcher爲
<TextSwitcher
android:id="@+id/switcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="World" />
</TextSwitcher>
。
您還可以以編程方式爲任何View對象啓動動畫。
Animation fadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
textView.startAnimation(fadeIn);