Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Android中显示此图像?_Android_Imageview_Android Layout_Resolution Independence - Fatal编程技术网

如何在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

如何在Android中显示具有以下配置的图像

  • 保留原始纵横比(图像可以缩放,但不能拉伸)
  • 填充父对象的宽度
  • 与父对象的底部对齐
以下操作不起作用:

<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).