80,350
社区成员
发帖
与我相关
我的任务
分享
<Button android:id="@+id/framebyframe" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Frame By Frame">
</Button>
<ImageView android:id="@+id/myImage" android:layout_width="140dip"
android:layout_height="140dip">
</ImageView>
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/a" android:duration="200" />
<item android:drawable="@drawable/b" android:duration="200" />
<item android:drawable="@drawable/c" android:duration="200" />
<item android:drawable="@drawable/d" android:duration="200" />
<item android:drawable="@drawable/e" android:duration="200" />
<item android:drawable="@drawable/f" android:duration="200" />
<item android:drawable="@drawable/g" android:duration="200" />
<item android:drawable="@drawable/h" android:duration="200" />
<item android:drawable="@drawable/i" android:duration="200" />
</animation-list>
final ImageView myImage = (ImageView) findViewById(R.id.myImage);
Button button = (Button) findViewById(R.id.framebyframe);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
myImage.setBackgroundResource(R.layout.frameanimation);
AnimationDrawable frameAnimation = (AnimationDrawable) myImage
.getBackground();
frameAnimation.start();
}
});