Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Drawable.createFromStream以一半大小加载图像_Android_Drawable - Fatal编程技术网

Android Drawable.createFromStream以一半大小加载图像

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.

如果我有一个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);

你为什么不把你的照片改成可绘制的而不是资产呢?