Android裁剪图像视图

Android裁剪图像视图,android,image,Android,Image,这是我的ImageView <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="150dp" /> 问题是ImageView和加载的图像中存在填充 有图像显示填充: 我使用.fit()方法来避免这种差距,但会造成图像拉伸和质量损失 (你现在可以看到这个深蓝色的圆圈是椭圆形的) 问题是: 如何避免图像质量下降,并直接将其调

这是我的
ImageView

<ImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="150dp" />
问题是
ImageView
和加载的图像中存在填充

有图像显示填充:

我使用
.fit()
方法来避免这种差距,但会造成图像拉伸和质量损失

(你现在可以看到这个深蓝色的圆圈是椭圆形的)

问题是: 如何避免图像质量下降,并直接将其调整为
ImageView
。我无法添加
.centerCrop()
,因为图像左侧是逻辑安全区。此外,我无法更改
布局\u height=“150dp”
,因为它将破坏我的所有布局


无论如何,谢谢你

查看您的图像视图:

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="150dp" />

您正在强制图像拉伸到其父视图的宽度(屏幕可能?)。尝试对宽度使用
wrap\u content
,并保持高度不变。这可能会导致图像缩小,但取决于您所需的用户体验

@stefs发现添加以下内容:

…android:adjustViewBounds=“true”/>

会有帮助的。看看这篇文章


如果您想要静态图像大小,您可能必须处理填充。

使用质量更好的图像,但不幸的是,这对我没有帮助,
android:adjustViewBounds=“true”/
在all@VLeonovs您是否也尝试将宽度更改为
wrap\u content
?好的。这些图像是方形的还是矩形的。我认为图像是从它原来的样子延伸出来的,这就是为什么它是这样的。张贴原始图像以便我们可以看到它们。
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="150dp" />