Step to perform animation in android apps
Step 1) Create XML which define animation
create a xml file which define the animation in res ⇒ anim ⇒ animation.xml , If you dont have anim folder then create it in res directory
blink.xml
Step 1) Create XML which define animation
create a xml file which define the animation in res ⇒ anim ⇒ animation.xml , If you dont have anim folder then create it in res directory
blink.xml
<? xml version = "1.0" encoding = "utf-8" ?> < alpha android:fromAlpha = "0.0" android:toAlpha = "1.0" android:interpolator = "@android:anim/accelerate_interpolator" android:duration = "800" android:repeatMode = "reverse" android:repeatCount = "infinite" /> </ set >
Step 2) Load the animation and set to view in acitvity to see blink effect
public class BlinkActivity extends Activity{ TextView textMessage; // Animation Animation animBlink; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_blink); textMessage = (TextView) findViewById(R.id.textMessage);
textMessag.setText(Welcome to Android Code Portal); // load the animation animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink); // start the animation textMessage.startAnimation(
animBlink ); } } Some other useful animations as follows
1)Blink
|
No comments:
Post a Comment