[英]Center view during simple scale animation
I'm trying to do a scale in/out animation for activity/framgent transition 我正在尝试为活动/脆弱过渡做一个放大/缩小动画
here are the two animations : 这是两个动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" >
<scale
android:fromXScale="80%"
android:fromYScale="80%"
android:toXScale="80%"
android:toYScale="80%" />
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.5" />
</set>
- --
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:interpolator="@android:anim/accelerate_decelerate_interpolator" >
<translate
android:fromXDelta="100%"
android:fromYDelta="0"
android:toXDelta="0"
android:toYDelta="0" />
</set>
Use it like that : 像这样使用它:
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_to_behind);
The problem is that the activity doesn't scale down in the center of the screen, it stick to the top/left of the screen 问题是活动不会在屏幕中央缩小,而是停留在屏幕的顶部/左侧
Any idea what wm i missing ? 知道我会错过什么吗? Or doing wrong ?
还是做错了?
Add a pivot to your scale animation. 将透视图添加到比例动画。 Add this on your xml:
在您的xml上添加此代码:
android:pivotX="50%"
android:pivotY="50%"
Your scale should look like: 您的比例应如下所示:
<scale
android:fromXScale="100%"
android:fromYScale="100%"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="80%"
android:toYScale="80%" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.