我想在水平viewpager中显示一组图像.我使用了Universal Image Loader一切都很好.但是在缩放之后,即使对于大图像,图像的质量也会丢失.
图像尺寸为1000*1000
我已配置以下设置
Options options = new DisplayImageOptions.Builder()
.showImageForEmptyUri(R.drawable.ic_launcher)
.cacheOnDisc()
.cacheInMemory()
.imageScaleType(ImageScaleType.POWER_OF_2)
.build();
config = new ImageLoaderConfiguration.Builder(ctx)
.defaultDisplayImageOptions(options)
.build();
ImageLoader.getInstance().init(config);
Run Code Online (Sandbox Code Playgroud) 我在monodroid中使用android 通用图像加载器为我的Android应用程序.
有一段时间我需要在SD卡中保存一些图像.在这种情况下,我需要在流中下载图像,然后将它们保存到SD卡.
有没有办法通过这个库下载图像流.因为在很多情况下图像被缓存在库中?
我有以下TextView布局:
<TextView
android:layout_width="10dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:drawableTop="@drawable/ic_launcher" >
Run Code Online (Sandbox Code Playgroud)
我在代码中夸大了这个布局,并希望使用Android-Universal-Image-Loader将图像加载到drawableTop中.但是,据我所知,没有办法从TextView获取backgroundTop的ImageView,因此我无法使用AUIL.有没有办法让ImageView为背景,如果没有,我应该如何修改布局,使其具有ImageView但看起来与原始布局相同?
在Lazy-List我使用此代码和我的图像存储在名为的文件夹中LazyList
ImageLoader imageLoader=new ImageLoader(context);
imageLoader.DisplayImage(url, imageView);
但在Universal-Image-Loader我使用这个
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.build();
ImageLoader.getInstance().init(config);
img = (ImageView) this.findViewById(R.id.test_id);
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage(URL.RECIPE_IMG_URL,img);
Run Code Online (Sandbox Code Playgroud)
但每次使用互联网来获取图像,并没有我的形象店口ASLO任何文件夹中一次添加.diskCache(new UnlimitedDiscCache(new File("myFolder")))到config
,但没有商店myFolder.任何想法?
android android-image android-lazyadapter android-imageview universal-image-loader
编辑:我解决了这个更新UIL库到1.8.0,因为在早期版本中没有从资产文件夹添加图像的功能.我确实错过了.
我正在使用Universal Image Loader库在ListView中显示图像列表
如果图像不存在,我想从drawable或asset文件夹加载占位符.
在库文档上,这是可接受的URI:
String imageUri = "assets://image.png"; // from assets
String imageUri = "drawable://" + R.drawable.image; // from drawables
Run Code Online (Sandbox Code Playgroud)
但使用任一选项都会触发a java.lang.NullPointerException
这是我的onResume方法,我加载我的图像:
@Override
public void onResume() {
super.onResume();
//open connection to db
db = new DBAdapter(this);
db.open();
// get all defects for this unit
defectList = db.getAllDefectsByUnit(unit_id);
// create an array adapter and let it to display our row
defects = new SimpleCursorAdapter(this, R.layout.defect_row, defectList, new String[] { "defect", "image_path" }, new int[] { R.id.defect, …Run Code Online (Sandbox Code Playgroud)