I post a question here because I canβt find a solution to my problem. I read a lot about android animation.
I am really developing an application for Android 4.0, and I need to animate the transition between the fragments (and not the layout).
Similary post, works with layout, but no more accurately about fragments
Here is my incomplete code:
Operation code
private void showFragment(final Fragment fragment) { if (null == fragment) return; FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_right); ft.replace(R.id.fragment_container_layout, fragment, fragment.getClass().getSimpleName()).commit(); }
R.anim.slide_in_left
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@android:integer/config_mediumAnimTime"> <translate android:fromXDelta="100%p" android:toXDelta="0" /> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" /> </set>
And finally R.anim.slide_out_right
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@android:integer/config_mediumAnimTime" > <translate android:fromXDelta="0" android:toXDelta="-100%p" /> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" /> </set>
When I run this code, I have an exception: 12-27 15: 26: 55.566: E / AndroidRuntime (27699): java.lang.RuntimeException: Unknown animator name: translate
Do you have an idea to fix this?
source share