2015-10-18 48 views

回答

0

我這樣做是使用下面的方法:)

public Bitmap getImageAlbumCover (Bitmap sourceBitmap) { 

     Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, 
       sourceBitmap.getWidth()-1, sourceBitmap.getHeight()-1); 
     int padding = 15; 
     int width = resultBitmap.getWidth(); 
     int height = resultBitmap.getHeight(); 

     Canvas canvas = new Canvas(resultBitmap); 
     Rect srcRect = new Rect(0, 0, width, height); 
     Rect desrect1 = new Rect((-1 * 1 * padding), (3 * padding) , width + (-1 * 1 * padding), height + (-1 * 3 * padding)); 
     Rect desrect2 = new Rect((-1 * 2 * padding), (2 * padding) , width + (-1 * 2 * padding), height + (-1 * 2 * padding)); 
     Rect desrect3 = new Rect((-1 * 3 * padding), (1 * padding) , width + (-1 * 3 * padding), height + (-1 * 1 * padding)); 



     Paint paint = new Paint(); 
     paint.setColor(Color.WHITE); 
     canvas.drawRect(0, 0, width, height, paint); 

     paint.setAlpha(64); 

     canvas.drawBitmap(sourceBitmap, srcRect, desrect1, paint); 

     paint.setAlpha(128); 

     canvas.drawBitmap(sourceBitmap, srcRect, desrect2, paint); 

     paint.setAlpha(255); 

     canvas.drawBitmap(sourceBitmap, srcRect, desrect3, paint); 

     return resultBitmap; 
    } 
0

您可以使用this library您的問題:

的代碼示例,也許是這樣的:

mageView mImageView; 
PhotoViewAttacher mAttacher; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // Any implementation of ImageView can be used! 
    mImageView = (ImageView) findViewById(R.id.iv_photo); 

    // Set the Drawable displayed 
    Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper); 
    mImageView.setImageDrawable(bitmap); 

    // Attach a PhotoViewAttacher, which takes care of all of the zooming functionality. 
    mAttacher = new PhotoViewAttacher(mImageView); 
} 


// If you later call mImageView.setImageDrawable/setImageBitmap/setImageResource/etc then you just need to call 
attacher.update(); 

否則你可以從Android的文檔過渡和動畫閱讀the documentation。甚至有很多例子。

+0

謝謝您的回答,但我並不需要動畫,我要作出這樣的拍攝圖像列表的列表視圖,併爲每個圖像它會爲具有不同不透明度值的相同圖像繪製三層視圖。 –