It’s up to us to define the alpha animation the way we want it. Alpha animations are generally used to fade drawable objects in and out based on the configuration. For our sample, we want to fade in our text from nothing over the course of three seconds. This configuration appears as below.
Create alpha.xml in anim folder of resources.
Create alpha.xml in anim folder of resources.
<?xml version="1.0" encoding="utf-8"?><alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="3000" />And write following code in the Java file Animation a = AnimationUtils.loadAnimation(this, R.anim.alpha); a.reset(); TextView tv = (TextView) findViewById(R.id.firstTextView); tv.clearAnimation(); tv.startAnimation(a); |
No comments:
Post a Comment