如果我的图像是512x512并且使用以下代码加载它,则IntrinsicWidth和Height值将以256x256的形式输入。有没有更好的方法从资源加载图像并获得适当的宽度/高度?
ImageView myImageView = new ImageView(theContext);
try {
InputStream ims = context.getAssets().open("Splash/clouds.png");
Drawable d = Drawable.createFromStream(ims, null);
myImageView.setImageDrawable(d);
myImageView .setMinimumWidth(d.getIntrinsicWidth());
myImageView .setMinimumHeight(d.getIntrinsicHeight());
}
catch (IOException e)
{
Log.e(TAG, "Splash: Load image", e);
}
addView(myImageView);