开发者

getBounds returning height & width 0

    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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜