Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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 在imageview中拉伸图像以适应xml格式的屏幕_Android_Xml_Imageview - Fatal编程技术网

Android 在imageview中拉伸图像以适应xml格式的屏幕

Android 在imageview中拉伸图像以适应xml格式的屏幕,android,xml,imageview,Android,Xml,Imageview,我有可绘制的图像,需要作为背景。它需要伸展才能填满屏幕。。 我知道如何使用java代码将图像拉伸到全屏。。但在XML中,它本身如何做到这一点。尝试使用此属性: android:scaleType="fitXY" 您可以找到其他用于调整大小的常量值。android:scaleType=“fitXY”将拉伸图像,以适合图像视图的完整大小。尝试像这样实现您的图像视图,并将ic_启动器更改为您自己尝试添加的图像名称 <ImageView android:id="@+id/mImage

我有可绘制的图像,需要作为背景。它需要伸展才能填满屏幕。。
我知道如何使用java代码将图像拉伸到全屏。。但在XML中,它本身如何做到这一点。

尝试使用此属性:

android:scaleType="fitXY"

您可以找到其他用于调整大小的常量值。

android:scaleType=“fitXY”将拉伸图像,以适合
图像视图的完整大小。

尝试像这样实现您的图像视图,并将ic_启动器更改为您自己尝试添加的图像名称

  <ImageView
    android:id="@+id/mImageView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitXY"
    android:src="@drawable/ic_launcher" />

希望这会有帮助。谢谢

我更喜欢使用scaleType=“centerCrop”。这样,图像就不会超出其原始比例