1 We have all seen the tile effect, so how can we achieve it? In fact, we mainly use the API. We can create a new bitmap at the beginning,, no one has ever thought about how to do this. So let's talk about the second method. XML is used. We have mentioned two methods above, but Android is very powerful. That is to say, we still have the third method, that is, we can draw it by ourselves, so let's take a look.CodeRight: 2 3 1 First, use the API provided by the system. 4 5 Bitmap bitmap = Bitmapfactory. decoderesource (getresources (), R. drawable. PIC ); 6 7 8 // Bitmap = bitmap. createbitmap (100, 20, config. argb_8888 ); 9 Bitmapdrawable drawable = New Bitmapdrawable (Bitmap ); 10 Drawable. settilemodexy (tilemode. Repeat, tilemode. Repeat ); 11 Drawable. setdither ( True ); 12 View. setbackgrounddrawable (drawable ); 13 14 15 2 ) Second, we use XML for easy implementation. 16 17 <Bitmap xmlns: Android = "http://schemas.android.com/apk/res/android" Android: src = "@ drawable/IMG" 18 Android: tilemode = "repeat"/> 19 20 3 (3) Draw it by yourself. 21 22 Public Static Bitmap createrepeater ( Int Width, bitmap SRC ){ 23 Int Count = (width + SRC. getwidth ()-1 )/ SRC. getwidth (); 24 25 Bitmap bitmap = Bitmap. createbitmap (width, SRC. getheight (), config. argb_8888 ); 26 Canvas canvas = New Canvas (Bitmap ); 27 28 For ( Int Idx = 0; idx <count; ++Idx ){ 29 Canvas. drawbitmap (SRC, idx * SRC. getwidth (), 0, Null ); 30 } 31 32 Return Bitmap; 33 }