From 17e25d6c856e77a18d4c4989ea4f70f374c6df73 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Thu, 24 Mar 2022 14:13:29 +0800 Subject: [PATCH] add animation to setting fragment --- .../ui/activity/MoreSettingActivity.java | 47 +++++++++++++++++-- app/src/main/res/anim/fragment_enter.xml | 15 ++++++ app/src/main/res/anim/fragment_enter_pop.xml | 15 ++++++ app/src/main/res/anim/fragment_exit.xml | 15 ++++++ app/src/main/res/anim/fragment_exit_pop.xml | 15 ++++++ 5 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/anim/fragment_enter.xml create mode 100644 app/src/main/res/anim/fragment_enter_pop.xml create mode 100644 app/src/main/res/anim/fragment_exit.xml create mode 100644 app/src/main/res/anim/fragment_exit_pop.xml diff --git a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java index 3a5e2ef..121cafd 100644 --- a/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java +++ b/app/src/main/java/xyz/fycz/myreader/ui/activity/MoreSettingActivity.java @@ -11,6 +11,8 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.NumberPicker; @@ -103,6 +105,9 @@ public class MoreSettingActivity extends BaseActivity { binding.svContent.setVisibility(View.GONE); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + binding.svContent.startAnimation(exitAnim); + FragmentTransaction ft = getSupportFragmentManager() + .beginTransaction() + .setCustomAnimations( + R.anim.fragment_enter, + R.anim.fragment_exit, + R.anim.fragment_enter_pop, + R.anim.fragment_exit_pop + ); if (mProxyFragment == null) { mProxyFragment = new ProxyFragment(); ft.add(R.id.ll_content, mProxyFragment); @@ -257,7 +272,15 @@ public class MoreSettingActivity extends BaseActivity { binding.svContent.setVisibility(View.GONE); - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + binding.svContent.startAnimation(exitAnim); + FragmentTransaction ft = getSupportFragmentManager() + .beginTransaction() + .setCustomAnimations( + R.anim.fragment_enter, + R.anim.fragment_exit, + R.anim.fragment_enter_pop, + R.anim.fragment_exit_pop + ); if (mWebDavFragment == null) { mWebDavFragment = new WebDavFragment(); ft.add(R.id.ll_content, mWebDavFragment); @@ -609,7 +632,15 @@ public class MoreSettingActivity extends BaseActivity + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fragment_enter_pop.xml b/app/src/main/res/anim/fragment_enter_pop.xml new file mode 100644 index 0000000..6a1d9f3 --- /dev/null +++ b/app/src/main/res/anim/fragment_enter_pop.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fragment_exit.xml b/app/src/main/res/anim/fragment_exit.xml new file mode 100644 index 0000000..59ca284 --- /dev/null +++ b/app/src/main/res/anim/fragment_exit.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fragment_exit_pop.xml b/app/src/main/res/anim/fragment_exit_pop.xml new file mode 100644 index 0000000..c39aaf6 --- /dev/null +++ b/app/src/main/res/anim/fragment_exit_pop.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file