一.在drawable文件夹中添加自己的my.xml文件
<?xml version ="1.0" encoding ="utf-8" ?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/img"
android:tileMode="repeat" />
二.然后再需要用的地方使用
android:background="@drawable/my"
三.代码实现方式
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
BitmapDrawable bd = new BitmapDrawable(bitmap);
bd.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT );
bd.setDither(true);
view.setBackgroundDrawable(bd);