android GridView实现选中图片放大

http://www.55zm.com/a/20130119/40937.html


getView里面
if (max_position != position) {
holder.image.setImageBitmap(bitmap);
holder.image.setScaleType(ScaleType.CENTER);
} else {
holder.image.setScaleType(ScaleType.MATRIX );
//获得Bitmap的高和宽
int bmpWidth=bitmap.getWidth(); 
int bmpHeight=bitmap.getHeight(); 
//产生resize后的Bitmap对象 
Matrix matrix=new Matrix();
matrix.setScale(1.05f, 1.05f);
Bitmap resizeBmp=Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true); 
holder.image.setImageBitmap(resizeBmp);
}


private int max_position;
public void notifyDataSetChanged(int position) {
max_position = position;
notifyDataSetChanged();
}

也可以直接

if (max_position != position) {
holder.image.setImageBitmap(bitmap);
holder.image.setScaleType(ScaleType.CENTER_INSIDE);
} else {
holder.image.setImageBitmap(bitmap);
holder.image.setScaleType(ScaleType.CENTER_CROP);
}


你可能感兴趣的:(android GridView实现选中图片放大)