[英]Android gallery setting image from assest folder
我想使用assest文件夹中的文件设置画廊的图像。
Try the following with an assets folder such as /assets/images/myimage.jpg 尝试使用资产文件夹(例如/assets/images/myimage.jpg)进行以下操作
String imagePath = "images/myimage.jpg"
Bitmap bmp = null;
try{
InputStream is = getAssets().open(imagePath);
bmp = BitmapFactory.decodeStream(is);
}
catch(Exception exception)
{
bmp = BitmapFactory.decodeResource(getResources(), R.drawable.icon_grey_box);
}
((ImageView)findViewById(R.id.myimage)).setScaleType(ImageView.ScaleType.CENTER_CROP);
((ImageView)findViewById(R.id.myimage)).setImageBitmap(bmp);
Just also thought, if your using GalleryView, and have a dataprovider then you might be able to format the image paths using 还要考虑一下,如果您使用GalleryView并有一个数据提供程序,那么您也许可以使用
file://mnt/sdcard/imageassets/ 文件:// mnt / sdcard / imageassets /
I think there is also a way to access your apk assets folder, using a URI path, similar to 我认为还有一种使用URI路径访问apk资产文件夹的方法,类似于
"android.resource://[package]/[res id]" “ android.resource:// [package] / [res id]”
This explains it well. 这很好地解释了。
http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.