HTML tile effect, then we are how to achieve that, we actually mainly use the API, we start new a bitmap, we can, then we say the second method, it is used in XML, above we said two methods, But Android is very powerful, that is to say we have a third method, that is, we draw it ourselves, the code is as follows:
The first type:
(1) The first implementation of Java code using the system-provided API: Bitmap Bitmap = Bitmapfactory.decoderesource (Getresources (), r.drawable.pic);//bitmap = Bitmap.createbitmap (+, config.argb_8888); Bitmapdrawable drawable = new Bitmapdrawable (bitmap);d rawable.settilemodexy (Tilemode.repeat, tilemode.repeat); Drawable.setdither (True); view.setbackgrounddrawable (drawable);
The second type:
(2) The second kind we use XML to easily implement Java code:< bitmap xmlns:android= "http://schemas.android.com/apk/res/android" android:src= "@ Drawable/img "android:tilemode=" repeat "/>
The third type:
(3) The third kind draws out the Java code: public static Bitmap createrepeater (int width, Bitmap src) {int count = (width + src.getwidth ()-1)/SR C.getwidth (); Bitmap Bitmap = Bitmap.createbitmap (width, src.getheight (), config.argb_8888); Canvas canvas = new canvas (bitmap), for (int idx = 0; idx < count; + + idx) {canvas.drawbitmap (src, idx * src.getwidth (), 0 , null);} return bitmap;}
3 ways to implement an Android image tiling effect