Android-Universal-Image-Loader调整视图边界不起作用

时间:2014-09-09 03:00:22

标签: android android-imageview universal-image-loader

我使用Android-Universal-Image-Loader并且图像尺寸有问题。

我在扩展的Application类中设置了ImageLoaderConfiguration:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
        .threadPriority(Thread.NORM_PRIORITY - 2)
        .denyCacheImageMultipleSizesInMemory()
        .diskCacheFileNameGenerator(new Md5FileNameGenerator())
        .diskCacheSize(50 * 1024 * 1024) // 50 Mb
        .tasksProcessingOrder(QueueProcessingType.LIFO)
        .writeDebugLogs() // Remove for release app
        .build();
ImageLoader.getInstance().init(config);

并设置DisplayImageOptions,如:

DisplayImageOptions options = new DisplayImageOptions.Builder()
        .showImageOnLoading(R.drawable.ic_loading)
        .showImageForEmptyUri(R.drawable.ic_loading_failed)
        .showImageOnFail(R.drawable.ic_loading_failed)
        .cacheInMemory(true)
        .cacheOnDisk(true)
        .considerExifParams(true)
        .displayer(new RoundedBitmapDisplayer(20))
        .build();

我动态创建ImageView,如:

ImageView imageView = new ImageView(context);
LinearLayout.LayoutParams layoutImage = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
layoutImage.setMargins(0, 0, 8, 0);
imageView.setLayoutParams(layoutImage);
imageView.setAdjustViewBounds(true);

我从本地SD卡加载图像。但是加载的图像被裁剪为 1dp width 和父高度。包装内容和adjustViewBounds无法正常工作。

寻找任何建议,谢谢!

0 个答案:

没有答案