首页 > 移动平台 > 详细

How to set background image to a LinearLayout using Android-Universal-Image-Loader ? #594

时间:2014-10-08 23:25:57      阅读:401      评论:0      收藏:0      [点我收藏+]

You can do it by 2 ways:

  • use loadImage(...) and set layout background in listener (ImageLoadingListener.onLoadingComplete(..., Bitmap loadedImage, ...))
  • Implement ImageAware which will wrap LinearLayout (like ImageViewAware). At this moment you can find ViewAware class in repository which does the main work for it. You should just extend it like this:
  • public class BgViewAware extends ViewAware {
    
        public BgViewAware(View view) {
            super(view);
        }
    
        public BgViewAware(View view, boolean checkActualViewSize) {
            super(view, checkActualViewSize);
        }
    
        @Override
        protected void setImageDrawableInto(Drawable drawable, View view) {
            view.setBackgroundDrawable(drawable);
        }
    
        @Override
        protected void setImageBitmapInto(Bitmap bitmap, View view) {
            view.setBackgroundDrawable(new BitmapDrawable(view.getResources(), bitmap));
        }
    }
    

    And then you can pass this BgViewAware (new BgViewAware(linearLayout)) into displayImage(...) method.
    But ViewAware class isn‘t released yet. It will be available in UIL 1.9.2.

https://github.com/nostra13/Android-Universal-Image-Loader/issues/594

How to set background image to a LinearLayout using Android-Universal-Image-Loader ? #594

原文:http://www.cnblogs.com/savagemorgan/p/4011409.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!