Android app overridePendingTransition not shown -
i have app main activity
using webview
load webpage.
i trying set animation when user wants go previous webpage using button on device (not button on screen) animation not shown @ all.
the code below outside of oncreate()
.
note: notice tried overridependingtransition
in each line commented out no effect.
here code:
@override public boolean onkeydown(int keycode, keyevent event) { log.i("back", " pressed!"); //overridependingtransition(r.anim.slide_in_right, r.anim.slide_out_left); if ((keycode == keyevent.keycode_back) && this.webview.cangoback()) { //overridependingtransition(r.anim.slide_in_right, r.anim.slide_out_left); this.webview.goback(); return true; } else{ return super.onkeydown(keycode, event); } } @override public void onbackpressed(){ super.onbackpressed(); //overridependingtransition(r.anim.slide_in_right, r.anim.slide_out_left); //finish(); return; }
if use finish()
exits app instead of going back.
here slide_in_right xml:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromxdelta="100%" android:toxdelta="0%" android:duration="500" /> <alpha android:duration="500" android:fromalpha="0.0" android:toalpha="1.0" /> </set>
and slide_out_left:
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromxdelta="0%" android:toxdelta="-100%" android:duration="500" /> <alpha android:duration="500" android:fromalpha="1.0" android:toalpha="0.0" /> </set>
i not sure missing. have checked lot of topics couldn't fix mine issue.
thanks in advance.
here solution!!!
call overridependingtransition after finishing activity
@override public void onbackpressed() { super.onbackpressed(); finish(); overridependingtransition(r.anim.activity_backin, r.anim.activity_back_out); }
activity_backin.xml in anim
folder
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="200" android:fromxdelta="-100%" android:toxdelta="0%" /> </set>
activity_back_out.xml in anim
folder
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="200" android:fromxdelta="0%" android:toxdelta="100%" /> </set>
Comments
Post a Comment