Fading in text in Android using AnimationUtils.loadAnimation -


i grateful if explain me why works:

private void startanimating() {     textview logo1 = (textview) findviewbyid(r.id.shizzle);            final animation fade1 = new alphaanimation(0.0f, 1.0f);           fade1.setduration(3000);         logo1.startanimation(fade1);         } 

but doesn't work @ me:

private void startanimating() {     textview logo1 = (textview) findviewbyid(r.id.shizzle);            animation fade1 = animationutils.loadanimation(this,r.anim.fade_in);       logo1.startanimation(fade1);         } 

the fade_in.xml associated above is:

    <?xml version="1.0" encoding="utf-8"?> <set     xmlns:android="http://schemas.android.com/apk/android"     android:shareinterpolator="false">     <alpha         android:fromalpha="0.0"         android:toalpha="1.0"         android:duration="3000">     </alpha> 

thanks help!

works me: create 2 file in folder /res/anim - fadein.xml, fadeout.xml

fadein:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false" >      <alpha         android:duration="500"         android:fromalpha="0.0"         android:toalpha="1.0" >     </alpha>  </set> 

fadeout:

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"     android:shareinterpolator="false" >      <alpha         android:duration="200"         android:fromalpha="1.0"         android:toalpha="0.0" >     </alpha>  </set> 

initialize code:

animation animfadein, animfadeout; ... animfadein=animationutils.loadanimation(this, r.anim.fadein); animfadeout=animationutils.loadanimation(this, r.anim.fadeout); 

... using:

case r.id.imgbtnshowcontent:     rlorderbtns.startanimation(animfadein);     rlorderbtns.setvisibility(view.visible); break;  case r.id.imgbtnhidecontent:     rlorderbtns.startanimation(animfadeout);     rlorderbtns.setvisibility(view.invisible); break; 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -