【问题标题】:ImageView making the border bigger than the imageImageView 使边框大于图像
【发布时间】:2017-10-06 18:30:52
【问题描述】:

我对 XML 和 Android Studio 还很陌生,但属性“wrap_content”不应该将自己包裹在图像周围吗? 使用此代码,ImageView 看起来像这样ImageView bigger than image

<ImageView
    android:id="@+id/slika"
    android:src="@drawable/kava"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:adjustViewBounds="false" />

如果我将 adjustViewBounds 更改为“true”,它看起来不错,但在纵向模式下会搞砸一切。 Like this

【问题讨论】:

  • 你发现了吗?
  • 你也可以试试android:scaleType="centerInside"android:scaleType="centerCrop"。如果你不希望你的图像被裁剪,你也可以试试这个android:adjustViewBounds="true"android:layout_centerInParent="true"

标签: xml android-studio android-studio-2.3


【解决方案1】:

如果图像大于屏幕,ImageView 无论如何都会适合它,为此它需要在其周围添加空白(如果图像大部分是水平的,它将在上方和下方添加空间它)。

为了适应它并丢弃空格,我发现唯一有效的属性是android:adjustViewBounds="true"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-20
    • 1970-01-01
    相关资源
    最近更新 更多