我有一个ImageView并对它进行了一个简单的缩放动画。非常标准的代码。
我的scale_up.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="1"
android:fromYScale="1"
android:toXScale="1.2"
android:toYScale="1.2"
android:duration="175"/>
</set>
我的动画代码:
Animation a = AnimationUtils.loadAnimation(this, R.anim.scale_up);
((ImageView) findViewById(R.id.circle_image)).startAnimation(a);
问题:
当图像缩放时,它不是从中心缩放,而是从左上角缩放。换句话说,图像的缩放版本没有与中心相同的点,但它具有相同的左上角点。 这张图片解释了我的意思:
第一张图片显示了动画如何缩放,第二张图片显示了我想要的缩放方式,应该保持中心点不变。 我尝试过在图像上设置重力、在容器上对齐左侧或右侧,但它总是以相同的方式缩放。 我在主屏幕上使用RelativeLayout,ImageView位于另一个RelativeLayout中,但我尝试了其他布局也没有变化。
50%p
,而不是XML? - Nikola K.