2011-01-06 2 views
0

は、私はいくつかのコードを持っていたが、それは 別のイメージの後にアニメーションイメージを使用するにはどうしたらいいですか?私は1枚の画像をしたい場合、我々は別の画像 後にアニメーションを使用する方法

Context mContext; 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.animationdemo); 
    Resources res = mContext.getResources(); 
    TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.transitiondrawable); 
    ImageView image = (ImageView) findViewById(R.id.imgView); 
    image.setImageDrawable(transition); 
    transition.startTransition(1000); 
} 

が動作していないと描画可能フォルダに1つのXMLファイルtransitiondrawable.xmlファイルを作っ

<transition xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/endoscope_"/> 
    <item android:drawable="@drawable/endoscope_2"/> 
</transition> 

と1つのレイアウトファイルanimationdemo.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center"> 


<ImageView 
android:id="@+id/imgView" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content"> 
</ImageView> 
</LinearLayout> 

私イム間違った考えを与えてください

あなたは、フレーム単位のアニメーションを使用する必要が

答えて

1

あなたはまた、線形の代わりに相対的なレイアウトを使用することができます。次に、2つのImageViewを重ねて重ねます。一番上にはフェードアウトアニメーションを使います。これにより、ある画像が別の画像に色あせてしまう効果が得られます

+0

私はこのテクニックを使用しており、相対レイアウトで動作しますが、LinearLayoutでは相対レイアウトのデフォルトは左上隅にすべてスタックするため、大変ありがとうございます – letroll

+0

ありがとうございます。線形レイアウトのデフォルトは、それらを1つの向きで次々に配置することです。 – FoamyGuy

関連する問題