Gilde加载网络图片到TextView的DrawableTop

来源:互联网 发布:深圳云计算招聘岗位 编辑:程序博客网 时间:2024/06/07 06:53

Gilde加载网络图片到TextView的DrawableTop

普通设置本地Drawable方法

代码块

代码块语法遵循标准markdown代码,例如:

 Drawable drawable1=getResources().getDrawable(R.drawable.lock);                    /// 这一步必须要做,否则不会显示.                    drawable1.setBounds(0,0,drawable1.getMinimumWidth(),drawable1.getMinimumHeight());tvTitle.setCompoundDrawables(drawable1,null,null,null);

所以遇到的问题就是如何将网络URL图片转化成Drawable图片并设置进去

具体方法看代码

 //网络加载成功更改tv drawable图片:private void openBidevent(List<HomeNewBean.IconsBean> mPictureList, final List<TextView> textViews, final List<ImageView> imageViews,String string) {        for(int i=0;i<mPictureList.size();i++){            final int finalI = i;       Glide.with(getActivity()).load(string+mPictureList.get(i).getPicPath()).asBitmap().into(new SimpleTarget<Bitmap>(){@OverrideGlideAnimation<? super Bitmap> glideAnimation) {  BitmapDrawable drawable= new BitmapDrawable(getActivity().getResources(), resource);                    /// 这一步必须要做,否则不会显示.                  drawable.setBounds(0,0,drawable.getMinimumWidth(),drawable.getMinimumHeight()); textViews.get(finalI).setCompoundDrawables(null,drawable,null,null);                }            });            textViews.get(i).setText(mPictureList.get(i).getTitle());        }    }
阅读全文
0 0
原创粉丝点击