直接在你的layout文件的开头加一个FrameLayout ,里面放一个ImageView,因为只有android:src可以设置android:scaleType,android:background是无法设置的,我的代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/main_background_normal_nextchapter"
android:scaleType = "centerCrop"
/>
</FrameLayout>
使用ImageView设置背景
本文介绍了一种在Android布局中使用ImageView来设置背景图片的方法,并详细解释了如何利用FrameLayout和ImageView实现图片填充整个屏幕,同时保持图片比例不失真。
814

被折叠的 条评论
为什么被折叠?



