![](https://img-blog.csdn.net/20130718102543390?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbXp6NTI0MA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
message_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/msg_bg"
android:tileMode="repeat"
android:dither="true"/>
用到该背景的xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/message_bg" >
也可以在java文件中用:
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.msg_bg);
BitmapDrawable bd = new BitmapDrawable(bitmap);
bd.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT );
bd.setDither(true);
view.setBackgroundDrawable(bd);