photo = (ImageView) findViewById(R.id.image1);
photo.setImageBitmap(pic);
Drawable drawable = photo.getDrawable();
imageBounds = dra开发者_运维知识库wable.getBounds();
int scaledHeight = imageBounds.height();
int scaledWidth = imageBounds.width();
Here scaledHeight & scaledWidth are zero. But i am getting the size of image correctly.
int intrinsicHeight = drawable.getIntrinsicHeight();
int intrinsicWidth = drawable.getIntrinsicWidth();
What is the problem imageBounds.height();
I think you use "photo" in the onCreate method. There, the ImageView dimensions are not still defined and I suggest you to put your code in the onWindowFocusChanged method, when "hasFocus" is true.
精彩评论