SetBackgroundDrawableResourceSetScaleType(android)
对不起,我的英语太差了,我只想使用SetBackgroundDrawableResourceSetScaleType(android),android,xml,Android,Xml,对不起,我的英语太差了,我只想使用getWindow()设置背景布局图像,如下所示: getWindow().setBackgroundDrawableResource(R.drawable.bg_image); 在bg\u图像中 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <
getWindow()
设置背景布局图像,如下所示:
getWindow().setBackgroundDrawableResource(R.drawable.bg_image);
在bg\u图像中
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:src="@drawable/bg_shkaf" />
</item>
</layer-list>
但这幅图被拉长了。如何按图片比例拉伸?如果只将图像指定给窗口背景,我认为不能指定缩放类型 在类似的场景中,我所做的是使用子
ImageView
将布局包装在父FrameLayout
中,该子ImageView
采用scaleType
属性。然后添加所有现有布局视图
例如:
<FrameLayout>
<ImageView
android:src="@drawable/bg_image"
android:scaleType="fitCenter"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<!-- all of your other views here ... -->
</FrameLayout>
如果只将图像指定给窗口背景,我认为您无法指定缩放类型 在类似的场景中,我所做的是使用子
ImageView
将布局包装在父FrameLayout
中,该子ImageView
采用scaleType
属性。然后添加所有现有布局视图
例如:
<FrameLayout>
<ImageView
android:src="@drawable/bg_image"
android:scaleType="fitCenter"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<!-- all of your other views here ... -->
</FrameLayout>
谢谢您的回答。我使用getWindow().setBackgroundDrawableResource(R.drawable.bg_image)代码>如果设置FrameLayout,则出现错误。。。。。。。。无效的可绘制标记框架布局
谢谢您的回答。我使用getWindow().setBackgroundDrawableResource(R.drawable.bg_image)代码>如果设置FrameLayout,则出现错误。。。。。。。。无效的可绘制标记框架布局
谢谢您的回答。我使用getWindow().setBackgroundDrawableResource(R.drawable.bg_image)代码>如果设置FrameLayout,则出现错误。。。。。。。。无效的可绘制标记框架布局