2014-12-07 60 views

回答

0

您可以通過getMeasuredWidth()檢測視圖的尺寸

而且使用Canvas和位圖繪製只是配合背景它

說你的圖片是100×50視圖是635 x 50

int viewWidth, picWidth. viewHeight; 
Bitmap pic; 
Paint paint; 
// set corresponding values in the variables above 

Canvas c=new Canvas(); 
Bitmap b=Bitmap.createBitmap(viewWidth, viewHeight,Config.ARGB_8888); 
c.setBitmap(b); 
int noOfPics= viewWidth/picWidth; 

int margin=(viewWidth-(noOfPics*picWidth))/(noOfPics-1); 

for(int i=0;i<noOfPics;i++){ 
    c.drawBitmap(pic, i*picWidth+margin*(i-1),0,paint); 
} 
相關問題