Android Drawable.createFromStream以一半大小加载图像
如果我有一个512x512的图像,并且我使用下面的代码加载它,则IntrinsicWidth和Height值为256x256。是否有更好的方法从资源加载图像并获得适当的宽度/高度Android Drawable.createFromStream以一半大小加载图像,android,drawable,Android,Drawable,如果我有一个512x512的图像,并且我使用下面的代码加载它,则IntrinsicWidth和Height值为256x256。是否有更好的方法从资源加载图像并获得适当的宽度/高度 ImageView myImageView = new ImageView(theContext); try { InputStream ims = context.getAssets().open("Splash/clouds.png"); Drawable d = Drawable.
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);
你为什么不把你的照片改成可绘制的而不是资产呢?