2012-05-09 11 views
1

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

これは、ほとんどのAndroid端末に付属しているGenie News and Weatherウィジェットと同様に、可能です。しかし、アニメーターやテキストスイッチャー(どちらもサポートされていないようです)を使用してこれがどのように行われているのかわかりません。

これはアラームを使用して行われたものではないと想定しています。これは、アニメーションの総オーバーキルのようです。

これはどのように行われているのですか? http://developer.android.com/guide/topics/resources/animation-resource.html#alpha-element

はあなたがアニメーションを開始しますか:

答えて

1

あなたがプログラム... ここでxmlファイルで定義されているアルファのアニメーションを、使用したりすることができますが、アニメーションについてのドキュメントですか?

2

あなたはそれが現在のテキストをフェードアウトし、新しいテキストにフェードインしますtextSwitcher上のsetTextを呼び出す場合は、その

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

ためViewSwitcherまたはTextSwitcherを使用することができます。


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

Animation fadeIn = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in); 
textView.startAnimation(fadeIn); 
関連する問題