Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Change lines:
- mFloatingActionButton.hide(); -> LayoutXyScaleAnim.hide(mFloatingActionButton, this);
- mFloatingActionButton.show(); -> LayoutXyScaleAnim.show(mFloatingActionButton, this);
- And the code for hide/show is actually:
- public static void show(final View target, Context context) {
- target.setVisibility(View.VISIBLE);
- AnimatorSet layoutShownAnim = (AnimatorSet) AnimatorInflater.loadAnimator(context, R.animator.layout_xy_scale_show);
- layoutShownAnim.setTarget(target);
- layoutShownAnim.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) { }
- @Override
- public void onAnimationEnd(Animator animation) { target.setVisibility(View.VISIBLE); }
- @Override
- public void onAnimationCancel(Animator animation) { }
- @Override
- public void onAnimationRepeat(Animator animation) {}
- });
- layoutShownAnim.start();
- }
- public static void hide(final View target, Context context) {
- AnimatorSet layoutHiddenAnim = (AnimatorSet) AnimatorInflater.loadAnimator(context, R.animator.layout_xy_scale_hide);
- layoutHiddenAnim.setTarget(target);
- layoutHiddenAnim.addListener(new Animator.AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) { }
- @Override
- public void onAnimationEnd(Animator animation) { target.setVisibility(View.GONE); }
- @Override
- public void onAnimationCancel(Animator animation) { }
- @Override
- public void onAnimationRepeat(Animator animation) {}
- });
- layoutHiddenAnim.start();
- }
- layout_xy_scale_show:
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:ordering="together">
- <objectAnimator
- android:duration="200"
- android:propertyName="scaleX"
- android:valueType="floatType"
- android:valueFrom="0.0f"
- android:valueTo="1.0f" />
- <objectAnimator
- android:duration="200"
- android:propertyName="scaleY"
- android:valueType="floatType"
- android:valueFrom="0.0f"
- android:valueTo="1.0f" />
- </set>
- layout_xy_scale_hide
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:ordering="together">
- <objectAnimator
- android:duration="200"
- android:propertyName="scaleX"
- android:valueType="floatType"
- android:valueFrom="1.0f"
- android:valueTo="0.0f" />
- <objectAnimator
- android:duration="200"
- android:propertyName="scaleY"
- android:valueType="floatType"
- android:valueFrom="1.0f"
- android:valueTo="0.0f" />
- </set>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement