简体   繁体   English

来自assest文件夹的Android画廊设置图像

[英]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.

相关问题 电子邮件的Android资产文件夹图像附件失败 - Android assest folder image attachment to email failed 从Assest加载图像时Android outofmemory - Android outofmemory while loading image from Assest Android Studio 1.0.2中的图像声明 - Image assest in Android Studio 1.0.2 Android从App文件夹创建图片库 - Android Create Image Gallery from App Folder 无法将图像从应用程序资产文件夹保存到Android中的图库文件夹? - Failed to save image from app assets folder to Gallery Folder in Android? 在Android中设置图片库视图 - Image setting Gallery view in android 如何使用Android应用程序从sqlite中的assest文件夹将表从一个数据库复制到另一个数据库 - How to copy table from one database to other database from assest folder in sqlite with an Android application 从sqlite数据库中检索数据并显示在android中的assest文件夹的HTML页面中 - Retrieve data from sqlite database and display in assest folder's HTML page in android 如何在Android中以编程方式将图像文件从图库复制到另一个文件夹 - How to Copy Image File from Gallery to another folder programmatically in Android 将图像从图库移动到Java android中受复制保护的文件夹中 - Move image from gallery to aplication protected folder in java android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM