Hi all,
Everyone wants application to be beautiful and attractive for an eye of a user. I'm searching for different type of animations in android after I found small animation look like a flag.
Now we’ll make it fade-in and fade-out. Create in appfolder /res folder new folder "anim" and add to it two Android XML files – appear.xml and disappear.xml. They will be alpha animations.
appear.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="800"
/>
</set>
disappear.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:interpolator="@android:anim/decelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="800"
/>
</set>
Here is a set of frames and “oneshot” attribute says to loop them. To run animation. Create flag.xml in drawable folder.
flag.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flaganim"
android:oneshot="false"
>
<item android:drawable="@drawable/f03" android:duration="100" />
<item android:drawable="@drawable/f04" android:duration="100" />
<item android:drawable="@drawable/f05" android:duration="100" />
<item android:drawable="@drawable/f06" android:duration="100" />
<item android:drawable="@drawable/f07" android:duration="100" />
<item android:drawable="@drawable/f08" android:duration="100" />
<item android:drawable="@drawable/f09" android:duration="100" />
<item android:drawable="@drawable/f10" android:duration="100" />
</animation-list>
Here the java code....
// Start animating the image
final ImageView ImageView = (ImageView) findViewById (R.id.ImageView);
ImageView.setBackgroundResource(R.drawable.flag);
final AnimationDrawable frameAnimation = (AnimationDrawable)ImageView.getBackground();
ImageView.post(new Runnable(){
@Override
public void run() {
frameAnimation.start();
}
});
Finally,
Image look like a flag:
No comments:
Post a Comment