ImageView额外填充问题

时间:2016-02-11 07:32:33

标签: android imageview android-imageview

ImageView代码:

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="?actionBarSize"
    android:contentDescription="@string/logo"
    android:layout_margin="@dimen/view_padding"
    android:padding="@dimen/view_padding"
    android:src="@drawable/home_logo"
    android:adjustViewBounds="true" />

API 17及以下:(问题)

enter image description here

API 18及以上:(所需结果)

enter image description here

正如您所看到的,在问题图像中左右两侧有额外的填充,其中所需的结果不存在。此外,我不想拉伸图像,甚至不改变高度。

PS:这些蓝色边界在开发人员设置中是“showLayoutBounds”选项。

1 个答案:

答案 0 :(得分:3)

代码: 用android:layout_width =&#34; wrap_content&#34;取一个LinearLayout;并将ImageView放在其中。