Hi,
Here I am adding sliding animation to DialogFragment
First I am adding animation xml in res/anim folder.
Then creating custom style that add to the particular fragmentdialogs's onStart() method.
slidestart.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="1000" android:fromydelta="100%p" android:toydelta="0">
</translate></set>
slideend.xml
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="1000" android:fromydelta="0" android:toydelta="100%p">
</translate></set>
Then create custom style in style folder
<style name="dialog_slide_animation">
<item name="android:windowEnterAnimation">@anim/slidestart</item>
<item name="android:windowExitAnimation">@anim/slideend</item>
</style>
Defining custom style in onStart() method.
public class myDialogFragment extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.custom_message_dialog, container,
false);
//Inflated custom xml , can do whatever we require.
return rootView;
}
@Override
public void onStart() {
super.onStart();
getDialog().getWindow().setWindowAnimations(
R.style.dialog_slide_animation);
}
}
0 Comment(s)