ImageView 额外填充问题
ImageView extra padding issue
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" />
API17岁以下:(问题)
API 18 岁及以上:(期望的结果)
如您所见,问题图像的左侧和右侧有额外的填充,而在期望的结果中却没有。我也不想拉伸图像,甚至不想改变高度。
PS:这些蓝色边界是开发者设置中的 "showLayoutBounds" 选项。
代码:
使用 android:layout_width = "wrap_content" 的 LinearLayout 并将其放在 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" />
API17岁以下:(问题)
API 18 岁及以上:(期望的结果)
如您所见,问题图像的左侧和右侧有额外的填充,而在期望的结果中却没有。我也不想拉伸图像,甚至不想改变高度。
PS:这些蓝色边界是开发者设置中的 "showLayoutBounds" 选项。
代码: 使用 android:layout_width = "wrap_content" 的 LinearLayout 并将其放在 ImageView 上方。