如何在Android中显示此图像?
如何在Android中显示具有以下配置的图像如何在Android中显示此图像?,android,imageview,android-layout,resolution-independence,Android,Imageview,Android Layout,Resolution Independence,如何在Android中显示具有以下配置的图像 保留原始纵横比(图像可以缩放,但不能拉伸) 填充父对象的宽度 与父对象的底部对齐 以下操作不起作用: <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="fitCenter" android:layout_alignParentBottom="true" android:src="@dra
- 保留原始纵横比(图像可以缩放,但不能拉伸)
- 填充父对象的宽度
- 与父对象的底部对齐
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_alignParentBottom="true"
android:src="@drawable/background" />
使用上面的xml,ImageView获取父对象的宽度,但ImageView中的图像不获取父对象的宽度。某些点。
如果您想控制纵横比而不是fitCenter,则应尝试:
请记住,使用应用程序的设备可能具有不同的屏幕大小。
如果您的背景图像是可以拉伸的,我建议您尝试一些点。
如果您想控制纵横比而不是fitCenter,则应尝试:
请记住,使用应用程序的设备可能具有不同的屏幕大小。
如果你的背景图像是可以拉伸的,我建议你尝试一个如果你能告诉我们什么不起作用会有帮助吗?如果你能告诉我们什么不起作用会有帮助吗?谢谢Macarse。背景可以缩放,但不能拉伸。另外,fitCenter不也应该保持纵横比吗?很抱歉我发现ScaleType的文档有点混乱。谢谢Macarse。背景可以缩放,但不能拉伸。另外,fitCenter不也应该保持纵横比吗?很抱歉我发现ScaleType的文档有点混乱。
Scale the image uniformly (maintain the image's aspect ratio) so
that both dimensions (width and height) of the image will be equal
to or less than the corresponding dimension of the view (minus padding).