日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
三種方法實(shí)現(xiàn)Android平鋪效果

需要實(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來輕松實(shí)現(xiàn),貌似是4.0以后出現(xiàn)的:

 
 
  1. android:src="../../@drawable/img" 
  2. Android:tileMode="repeat" />  

第三種,自己畫出來:

 
 
  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(), 0, null); 
  9.      } 
  10.  
  11.      return bitmap; 
  12. }  

網(wǎng)站名稱:三種方法實(shí)現(xiàn)Android平鋪效果
文章轉(zhuǎn)載:http://m.5511xx.com/article/dpeogee.html