【问题标题】:Bitmap in ImageView is getting cropped after rotationImageView 中的位图在旋转后被裁剪
【发布时间】:2016-06-30 15:35:43
【问题描述】:

我的 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"/>

【问题讨论】:

  • 您找到解决方案了吗?

标签: android bitmap rotation


【解决方案1】:

尝试改变

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);

【讨论】:

  • 感谢您的建议,但这个解决方案对我没有帮助(((
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-16
  • 2013-04-05
  • 2013-05-10
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
  • 1970-01-01
相关资源
最近更新 更多