天天看点

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();

也可以直接

holder.image.setscaletype(scaletype.center_inside);

holder.image.setscaletype(scaletype.center_crop);

继续阅读