偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

三種方法實(shí)現(xiàn)Android平鋪效果

移動(dòng)開(kāi)發(fā) Android
這里提供了三種方法實(shí)現(xiàn)Android平鋪效果,分別是利用系統(tǒng)提供的api實(shí)現(xiàn)、使用xml來(lái)輕松實(shí)現(xiàn)和自己畫出來(lái)。

需要實(shí)現(xiàn)平鋪效果,大致有幾下幾種方法。

***種,利用系統(tǒng)提供的api實(shí)現(xiàn):

  1. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic); 
  2.  
  3. //bitmap = Bitmap.createBitmap(200, 30, Config.ARGB_8888); 
  4. BitmapDrawable drawable = new BitmapDrawable(bitmap); 
  5. drawable.setTileModeXY(TileMode.REPEAT , TileMode.REPEAT ); 
  6. drawable.setDither(true); 
  7. view.setBackgroundDrawable(drawable);  

 第二種,使用xml來(lái)輕松實(shí)現(xiàn),貌似是4.0以后出現(xiàn)的:

  1. <bitmap xmlns:Android="http://schemas.android.com/apk/res/android"    
  2. android:src="../../@drawable/img" 
  3. Android:tileMode="repeat" />  

第三種,自己畫出來(lái):

  1. public static Bitmap createRepeater(int width, Bitmap src){ 
  2. int count = (width + src.getWidth() - 1) / src.getWidth(); 
  3.  
  4. Bitmap bitmap = Bitmap.createBitmap(width, src.getHeight(), Config.ARGB_8888); 
  5. Canvas canvas = new Canvas(bitmap); 
  6.  
  7.     for(int idx = 0; idx < count; ++ idx){ 
  8.         canvas.drawBitmap(src, idx * src.getWidth(), 0null); 
  9.      } 
  10.  
  11.      return bitmap; 
  12. }  

 

責(zé)任編輯:徐川 來(lái)源: OSChina
相關(guān)推薦

2021-07-13 12:31:27

IT組織改進(jìn)首席技術(shù)官

2009-07-08 12:56:32

編寫Servlet

2010-09-06 10:04:31

CSS樣式表

2022-07-13 16:06:16

Python參數(shù)代碼

2009-12-11 18:49:39

預(yù)算編制博科資訊

2024-11-15 07:00:00

Python發(fā)送郵件

2011-04-18 15:32:45

游戲測(cè)試測(cè)試方法軟件測(cè)試

2010-09-14 15:10:49

CSS注釋

2023-08-14 17:58:13

RequestHTTP請(qǐng)求

2011-06-10 10:43:12

Ubuntu應(yīng)用安裝

2009-06-23 10:45:18

Hibernate支持

2010-08-26 16:19:41

DIV圓角

2015-12-11 09:24:38

加密數(shù)據(jù)Linux

2010-09-30 15:37:29

ScrollBarJavascrip

2024-07-31 20:38:18

2023-05-16 16:07:07

大數(shù)據(jù)數(shù)據(jù)管理工具

2016-09-09 13:07:56

CentOSJDKLinux

2010-07-29 09:56:45

Flex數(shù)據(jù)庫(kù)

2023-09-25 15:08:43

Python方離群值

2021-09-10 18:09:42

SQL注入漏洞網(wǎng)絡(luò)攻擊
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)