java - Slide in another XML layout when button is clicked -
i have main.xml
layout file , in java code, doing calculation taken main
layout , wanting display in result.xml
layout file. know can use anim
folder hold animation slidei n result
layout following:
left right:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareinterpolator="false"> <translate android:fromxdelta="-100%" android:toxdelta="0%" android:fromydelta="0%" android:toydelta="0%" android:duration="700"/> </set>
right left:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareinterpolator="false"> <translate android:fromxdelta="0%" android:toxdelta="100%" android:fromydelta="0%" android:toydelta="0%" android:duration="700" /> </set>
i wondering how implement above when button clicked on main
layout file, result
layout file slides in right. , if wanted go main
layout can press button (added on result
layout) slide right main
layout file
you can use function : overridependingtransition can define animation upcoming activity , other animation activity exit.
use this, in second activity :
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); overridependingtransition(android.r.anim.slide_out_right, 0); setcontentview(r.layout.mylayout);
first argument animation enter, , 0 no animation.
and animation when leave second activity :
@override public void finish() { super.finish(); overridependingtransition(r.anim.enteranim, r.anim.leaveanim); }
Comments
Post a Comment