【问题标题】:Image disappears if i apply RoundedBitmapDisplayer() with Universal Image Loader如果我使用 Universal Image Loader 应用 RoundedBitmapDisplayer(),图像会消失
【发布时间】:2014-05-05 18:48:30
【问题描述】:

我正在使用通用图像加载器来加载一些图像,并且我想使用 RoundedBitmapDisplayer 功能。不使用它,图像加载完美,但如果我添加:

options = new DisplayImageOptions.Builder()
        .showStubImage(R.drawable.stub_image)
        .showImageForEmptyUri(R.drawable.image_for_empty_url)
        .cacheInMemory()
        .cacheOnDisc()
        .displayer(new RoundedBitmapDisplayer(20))     //this makes the issue
        .build();

整个图像消失并且根本不显示。即使值为 1,也会发生同样的情况。如果我省略那行,它显示没问题。我还想问一下这是否是使用imageloader的正确方式和顺序,所以有问题的伪代码,也许对回答我的主要问题更有帮助:

public class MyRoom{
...
DisplayImageOptions options;
ImageLoader imageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration config;
...

@Override
protected void onCreate(Bundle savedInstanceState) {
...
config = new ImageLoaderConfiguration.Builder(getApplicationContext())
         .build();
options = new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.stub_image)
            .showImageForEmptyUri(R.drawable.image_for_empty_url)
            .cacheInMemory()
            .cacheOnDisc()
            .displayer(new RoundedBitmapDisplayer(20))     //this makes the issue
            .build();
...
}


class RoomItemAdapter extends BaseAdapter {
...
public View getView(final int position, View convertView, ViewGroup parent) {
...
imageLoader = ImageLoader.getInstance();
imageLoader.init(config);
imageLoader.displayImage(Comment_img.get(position), viewHolder.img, options);
...
}
...
}

}

【问题讨论】:

  • 上,我在使用 roundedbitmapdisplayer 时也遇到了一些问题
  • 我也试过找其他的bitmapDisplayer,比如CircleBitmapDisplayer,也是让图片消失
  • (我的问题有点不同,我的图片已修改)如果你找到一个好的解决方案,我很感兴趣
  • 我昨天将我的图像加载器更新为 1.9.2,之前它使用的是 1.7.0 版本。但同时,如果我将 RoundedBitmapStlye 的值更改为 20,它不仅会舍入 imageview,还会通过放大修改图像。
  • 对我来说也一样,这很奇怪

标签: android imageview universal-image-loader


【解决方案1】:

将 ImageView 的 layout_width 和 layout_height 赋值为特定值:

<ImageView 
    android:id="@+id/image"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:contentDescription="@null"/>

【讨论】:

  • 谢谢,我会尽快尝试。
猜你喜欢
  • 2020-03-24
  • 2017-09-08
  • 2014-11-14
  • 1970-01-01
  • 2013-01-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多