画像ビューでフレームごとのアニメーションを適用しました。フレームごとに2つの画像を使用するだけです
main.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView iv = (ImageView) findViewById( R.id.imageView1);
iv.setBackgroundResource(R.anim.animation);
AnimationDrawable ac= (AnimationDrawable) iv.getBackground();
ac.start();
//ac.stop();
if(ac.isRunning()==false){
iv.setVisibility(View.INVISIBLE);
}
}
アニメーション.xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/image1" android:duration="1000"/>
<item android:drawable="@drawable/image2" android:duration="1000"/>
</animation-list>
activity_main.xml(レイアウト)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" />
</RelativeLayout>
また、このアニメーションを停止する場所がわかりません。2 つの画像がアニメーション化された後に画像ビューを非表示にして、後でアニメーションを再開する必要があります。
私は広告画像に取り組んでいます。そのため、画像を短時間表示する必要があり、後で再起動します。
誰かがこの解決策を知っていれば。私を助けてください。