【问题标题】:Remove white border around an ImageView删除 ImageView 周围的白色边框
【发布时间】:2012-12-04 17:23:08
【问题描述】:

我的设计师不断在我的图像周围添加一点填充。 我希望将图像棒在顶部并填充屏幕的宽度。

这是设计师的截图:

这是我的 XML 代码:

<ImageView
    android:id="@+id/markertap_header"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/header_bootsverleih_xhdpi" />

【问题讨论】:

  • 如果白色边框在图像本身,您应该手动裁剪图像一次,而不是每次运行应用时都尝试更改它。

标签: android android-layout android-imageview


【解决方案1】:

图片看起来比屏幕宽度大,所以在调整大小后会缩小。尝试将android:adjustViewBounds="true" 添加到您的ImageView

【讨论】:

    【解决方案2】:
     <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:id="@+id/imageView"
            android:cropToPadding="false"
            android:scaleType="fitXY" />
    

    当我将 ImageView 用于 Splashscreen 时也有同样的经历,这对我有用。

    【讨论】:

    • 这个答案要好得多,因为它在每种情况下都能完美地“修剪”图像。
    【解决方案3】:

    您可能只想将它添加到您的图像视图中。 它解决了我的问题。

    android:paddingVertical="0dp"
    android:paddingHorizontal="0dp"
    

    【讨论】:

      猜你喜欢
      • 2017-10-28
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多