mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-21 16:35:09 -05:00
MainActivity: Add animation when switching fragments.
This commit is contained in:
parent
6d843abbac
commit
408d4ee80e
@ -169,9 +169,13 @@ public class MainActivity extends ActionBarActivity implements YaaicActivity, Se
|
||||
private void switchToFragment(Fragment fragment, String tag) {
|
||||
drawer.closeDrawers();
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.container, fragment, tag);
|
||||
transaction.commit();
|
||||
getFragmentManager()
|
||||
.beginTransaction()
|
||||
.setCustomAnimations(
|
||||
R.animator.card_flip_right_in, R.animator.card_flip_right_out,
|
||||
R.animator.card_flip_left_in, R.animator.card_flip_left_out)
|
||||
.replace(R.id.container, fragment, tag)
|
||||
.commit();
|
||||
}
|
||||
|
||||
public void onAbout(View view) {
|
||||
|
20
app/src/main/res/animator/card_flip_left_in.xml
Normal file
20
app/src/main/res/animator/card_flip_left_in.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Before rotating, immediately set the alpha to 0. -->
|
||||
<objectAnimator
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0"
|
||||
android:propertyName="alpha"
|
||||
android:duration="0" />
|
||||
<objectAnimator
|
||||
android:valueFrom="-180"
|
||||
android:valueTo="0"
|
||||
android:propertyName="rotationY"
|
||||
android:interpolator="@android:interpolator/accelerate_decelerate"
|
||||
android:duration="@integer/card_flip_time_full" />
|
||||
<objectAnimator
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="@integer/card_flip_time_half"
|
||||
android:duration="1" />
|
||||
</set>
|
14
app/src/main/res/animator/card_flip_left_out.xml
Normal file
14
app/src/main/res/animator/card_flip_left_out.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:valueFrom="0"
|
||||
android:valueTo="180"
|
||||
android:propertyName="rotationY"
|
||||
android:interpolator="@android:interpolator/accelerate_decelerate"
|
||||
android:duration="@integer/card_flip_time_full" />
|
||||
<objectAnimator
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="@integer/card_flip_time_half"
|
||||
android:duration="1" />
|
||||
</set>
|
19
app/src/main/res/animator/card_flip_right_in.xml
Normal file
19
app/src/main/res/animator/card_flip_right_in.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0"
|
||||
android:propertyName="alpha"
|
||||
android:duration="0" />
|
||||
<objectAnimator
|
||||
android:valueFrom="180"
|
||||
android:valueTo="0"
|
||||
android:propertyName="rotationY"
|
||||
android:interpolator="@android:interpolator/accelerate_decelerate"
|
||||
android:duration="@integer/card_flip_time_full" />
|
||||
<objectAnimator
|
||||
android:valueFrom="0.0"
|
||||
android:valueTo="1.0"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="@integer/card_flip_time_half"
|
||||
android:duration="1" />
|
||||
</set>
|
14
app/src/main/res/animator/card_flip_right_out.xml
Normal file
14
app/src/main/res/animator/card_flip_right_out.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<objectAnimator
|
||||
android:valueFrom="0"
|
||||
android:valueTo="-180"
|
||||
android:propertyName="rotationY"
|
||||
android:interpolator="@android:interpolator/accelerate_decelerate"
|
||||
android:duration="@integer/card_flip_time_full" />
|
||||
<objectAnimator
|
||||
android:valueFrom="1.0"
|
||||
android:valueTo="0.0"
|
||||
android:propertyName="alpha"
|
||||
android:startOffset="@integer/card_flip_time_half"
|
||||
android:duration="1" />
|
||||
</set>
|
5
app/src/main/res/values/animation.xml
Normal file
5
app/src/main/res/values/animation.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<integer name="card_flip_time_full">800</integer>
|
||||
<integer name="card_flip_time_half">400</integer>
|
||||
</resources>
|
@ -12,7 +12,7 @@
|
||||
|
||||
<style name="FloatingActionButton" parent="android:Widget.Material.Button">
|
||||
<item name="android:background">@drawable/fab_background</item>
|
||||
<item name="android:stateListAnimator">@anim/fab_state_list_animator</item>
|
||||
<item name="android:stateListAnimator">@animator/fab_state_list_animator</item>
|
||||
<item name="android:layout_width">56dp</item>
|
||||
<item name="android:layout_height">56dp</item>
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user