Skip to content

Instantly share code, notes, and snippets.

@d4rkc0de
Created November 28, 2016 21:34
Show Gist options
  • Save d4rkc0de/1e6c3755dac0f908bacf895212f052bf to your computer and use it in GitHub Desktop.
Save d4rkc0de/1e6c3755dac0f908bacf895212f052bf to your computer and use it in GitHub Desktop.
Animation slide in/out using fragment and xml
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = (ViewGroup) inflater.inflate(R.layout.product_frame, null);
getFragmentManager().beginTransaction().replace(R.id.sub_header, new Sub_Header()).commit();
getFragmentManager().beginTransaction().setCustomAnimations(R.animator.slide_in_left,R.animator.slide_out_right, 0, 0)
.replace(R.id.product_frame, new Sub_Catagory_Grid()).commit();
return view;
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:propertyName="x"
android:valueFrom="1000"
android:valueTo="0"
android:valueType="floatType" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-1000"
android:valueType="floatType" />
</set>
@d4rkc0de
Copy link
Author

slide_out_right and slide_out_right should be placed inside animator folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment