我不知道如何让图像填满屏幕,尝试了一切,也许我应该使用一些特殊的布局..?
我正在使用ImageView,但这只占屏幕的70%左右,在底部留下空白......
目前我只是使用LinearLayout并将其背景设置为我的图像.虽然这填满了屏幕,但图像有轻微的拉伸,这是我不想要的.
任何帮助将不胜感激!:)
我的布局文件的ImageView标签内的代码是:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/image"
Run Code Online (Sandbox Code Playgroud)
Pad*_*mar 48
//在你的xml Image属性中
android:scaleType="fitXY"
Run Code Online (Sandbox Code Playgroud)
或//以编程方式使用
imgview.setScaleType(ScaleType.FIT_XY);
Run Code Online (Sandbox Code Playgroud)
注意:这适用于使用android:src ="..."而不是android:background ="..."设置图像时,默认情况下将背景设置为拉伸并适合视图.
小智 12
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:src="@drawable/image"
Run Code Online (Sandbox Code Playgroud)
只需更改布局宽度和高度,这将适用于'center'和'centercrop'