Android - Change Layout with an animation -


this first week of android development , having troubles please patient me.

this simple other answers weren't clear or detailed enough me apply it.

i trying switch "activity_main.xml" second .xml after button click. have connected button , put in setcontentview(r.layout.view) , works want animate. want view come right , opposite when user press back. doing in eclipse if helps.

thanks in advance!

assuming you're after transition between 2 activities, here's you're going need do:

  1. create new activity class. example, lets name mysecondactivity.

  2. in new activity class, make sure you're inflating new layout xml.

  3. in original activity class, open new activity intent, on new activity, call overridependingtransition animation want:

code sample:

intent intent = new intent(this, mysecondactivity.class); startactivity(intent); getactivity().overridependingtransition(android.r.anim.slide_in_left, android.r.anim.slide_out_right); 

in example, i'm using android pre-defined animations. can create own too, feel might enough needs.

hope helps.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -