ImageView显示有图片的,我打算获取该ImageView的bitmap对象,对其进行缩放。试了多种方法,但获取的bitmap都为null,代码如下:
gallery.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
view = (LinearLayout) arg1;
selectImageView = (ImageView) (arg1
.findViewById(R.id.image_show_gallery_items_imageview));
selectImageView.setDrawingCacheEnabled(true);
bitmap = selectImageView.getDrawingCache(); //这里得到的bitmap对象为null
selectImageView.setDrawingCacheEnabled(false);
//height = bitmap.getHeight();
//width = bitmap.getWidth();
//Utility.WriteLog(TAG, "width: " + width + " ,height: " + height);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
有人遇到过这种问题吗? |
|