gpt4 book ai didi

android - getBounds 返回高度和宽度 0

转载 作者:行者123 更新时间:2023-11-30 04:36:14 25 4
gpt4 key购买 nike

    photo = (ImageView) findViewById(R.id.image1);
photo.setImageBitmap(pic);
Drawable drawable = photo.getDrawable();
imageBounds = drawable.getBounds();
int scaledHeight = imageBounds.height();
int scaledWidth = imageBounds.width();

此处 scaledHeight 和 scaledWidth 为零。但是我正确地获取了图像的大小。

    int intrinsicHeight = drawable.getIntrinsicHeight();
int intrinsicWidth = drawable.getIntrinsicWidth();

imageBounds.height()有什么问题;

最佳答案

我认为您在 onCreate 方法中使用了“照片”。在那里,ImageView 尺寸仍未定义,我建议您将代码放在 onWindowFocusChanged 方法中,当“hasFocus”为真时。

关于android - getBounds 返回高度和宽度 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6800069/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com