我这样做的方法是为背景/drawable/backrepeat.xml 制作一个可在两个方向上重复图像(metalgrid.jpg)的可绘制对象。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/metalgrid"
android:tileMode="repeat"
android:dither="true" />
然后我就有了风格
<style name="page_background_gen">
<item name="android:background">@drawable/backrepeat</item>
</style>
然后我在我的布局中使用这种风格
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:id="@+id/relativeLayout1"
style="@style/page_background_gen"
android:layout_width="fill_parent">
....
</RelativeLayout>
这将用重复的图像填充背景,而不会混淆图像的比例。