我的 Android 项目中有一个 ImageView。在某些情况下我需要旋转这个 ImageView 。所有旋转都是在旋转动画的帮助下执行的。但是,当 ImageView 旋转 90 度或 270 度时,其中的位图会在顶部和底部被裁剪。我不知道为什么会这样。谁能给我建议如何避免这种行为?
final ImageView photoView = (ImageView) main_activity.findViewById(R.id.photo_view);
RotateAnimation mRotateAnim = new RotateAnimation(oldRotation, newRotation, photoView.getPivotX(), photoView.getPivotY());
mRotateAnim.setDuration(500);
mRotateAnim.setFillAfter(true);
photoView.startAnimation(mRotateAnim);
这是我在 xml 文件中的 ImageView 声明:
<ImageView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_above="@+id/bottom_container"
android:adjustViewBounds="true"/>
最佳答案
尝试改变
RotateAnimation mRotateAnim = new RotateAnimation(oldRotation, newRotation, photoView.getPivotX(), photoView.getPivotY());
与:
RotateAnimation mRotateAnim = new RotateAnimation(oldRotation, newRotation, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
关于android - ImageView 中的位图在旋转后被裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38127679/