设置Bitmap平铺效果

来源:互联网 发布:王者荣耀手办淘宝 编辑:程序博客网 时间:2024/06/05 20:09

1. 代码中利用api动态创建

 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image); BitmapDrawable drawable = new BitmapDrawable(bitmap); drawable.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT ); drawable.setDither(true); view.setBackgroundDrawable(drawable);

2. Xml中配置tileMode属性设置

 <bitmap xmlns:android="http://schemas.android.com/apk/res/android"          android:src="@drawable/img"           android:tileMode="repeat" />
0 0
原创粉丝点击