2

Androidウィジェットでテキストをアニメーション化しようとしています。具体的には、テキストをフェードインおよびフェードアウトさせたいと考えています。

ほとんどの Android ハンドセットに同梱されている Genie News and Weather ウィジェットがそうしているように、これが可能であることはわかっています。ただし、アニメーターまたはテキスト スイッチャーを使用してこれを行う方法がわかりません (どちらもサポートされていないようです)。

これはアニメーションとしてはやり過ぎのように思えるので、これはアラームを使用して行われたものではないと想定しています。

これがどのように行われるか知っている人はいますか?

4

2 に答える 2

2

そのために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>

textSwitcher で setText を呼び出すと、現在のテキストがフェードアウトし、新しいテキストがフェードインします。


また、任意の View オブジェクトのアニメーションをプログラムで開始することもできます。

Animation fadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
textView.startAnimation(fadeIn);
于 2012-05-09T13:55:45.437 に答える
1

XMLファイルまたはプログラムで定義されたアルファアニメーションを使用できます...アニメーションに関するドキュメントは次のとおりです

いつアニメーションを開始しますか?

于 2012-05-09T12:29:34.760 に答える