java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
将原有项目图片加载框架picasso改为glide,关于picasso和glide文档就自行查阅相关资料
显示 图片 例子
Glide.with(mContext).load(imageUrl).placeholder(defaultDrawable)
.error(defaultDrawable).dontAnimate().into(view) 显示正常
因为项目中头像是圆形利用glide实用圆头像代码如下
Glide.with(mContext)
.load(imageUrl)
.dontAnimate()
//.transform(new GlideRoundTransform(mContext,2))//方形圆解
.transform(new GlideCircleTransform2(mContext))//圆形
.into(view);
GlideCircleTransform2代码
public class GlideCircleTransform2 extends BitmapTransformation {
public GlideCircleTransform2(Context context) {
super(context);
}
@Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
return circleCrop(pool, toTransform);
}
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
@Override public String getId() {
return getClass().getName();
}
}
运行项目 提示我 java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting
直接开始google大法
搜索结果 http://stackoverflow.com/questions/34833627/error-you-must-not-call-settag-on-a-view-glide-is-targeting-when-use-glide/35096552#35096552
然后我将我的adapter时面全部涉及tag的全部去掉只留convertView的tag 然后在给convertView的tag加入key 区别与其它tag
if (convertView == null) {
convertView = mInflater.inflate(R.layout.broadcast_fragment_item,parent,false);
holder = new ViewHolder(convertView);
convertView.setTag(R.id.glide_tag,holder);
}else{
holder = (ViewHolder)convertView.getTag(R.id.glide_tag);
}
R.id.glide_tag是我在ids.xml定义了一个ID
java.lang.IllegalArgumentException: You must not call setTag() on a view Glide is targeting的更多相关文章
- You must not call setTag() on a view Glide is targeting
概述 在使用Glide加载图片时,如果出现"You must not call setTag() on a view Glide is targeting"的错误,八成是在使用Li ...
- Glide加载图片报错You must not call setTag() on a view Glide is targeting
报错信息为:You must not call setTag() on a view Glide is targeting 原因就是View使用setTag后导致Glide之前请求的标记被清除,强制转 ...
- You must not call setTag() on a view Glide is targeting when use Glide
以下代码是一个显示图片的RecyclerView 的Adapter用到的,当点击图片,跳到另一个Activity显示大图.RecyclerView 与ListView不同 然而没有setOnClick ...
- “You must not call setTag() on a view Glide is targeting” 解决
报错原因大致是因为Glide加载的iamgeView调用了setTag()方法导致的错误, 因为Glide已经默认为ImageView设置的Tag. 解决办法:自定义一个Application,在里面 ...
- [Android] View.setTag(key,Object) (java.lang.IllegalArgumentException: The key must be an application-specific resource id.)
转自: http://blog.csdn.net/brokge/article/details/8536906 setTag是android的view类中很有用的一个方法,可以用它来给空间附加一些信息 ...
- hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///
Java代码如下: FileSystem fs = FileSystem.get(conf); in = fs.open(new Path("hdfs://192.168.130.54:19 ...
- 严重: Error starting static Resources java.lang.IllegalArgumentException:
严重: Error starting static Resources java.lang.IllegalArgumentException: Document base E:\myworkspace ...
- Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
在学习struts 2时,为了方便,直接从下载的struts的apps目录下的struts2-blank.war压缩包下的WEB-INF\复制的web.xml,当我启动Tomcat时,发生 java. ...
- tomcat报错java.lang.IllegalArgumentException: Document base XXXXX does not exist or is not a readable directory
启动tomcat的时候报如下错误: java.lang.IllegalArgumentException: Document base F:\java\tools\tomcat\me-webapps\ ...
随机推荐
- JS-for中的i
var aBtn = document.getElementsByTagName('input'); for( var i=0; i<aBtn.length; i++ ){ ...
- jsp_设置错误页
在各个常用的web站点中,当一个页面出错后,会自动跳转到一个页面上进行错误信息的显示.下面我们说说这个操作是怎么实现的. 要想完成错误页的操作,在jsp页面必须满足两个条件: (1)指定错误出现时的跳 ...
- Postman-简单使用
Postman-简单使用 Postman-进阶使用 Postman-CI集成Jenkins Postman功能(https://www.getpostman.com/features) 主要用于模拟网 ...
- day5----正则
%a 本地(locale)简化星期名称 %A 本地完整星期名称 %b 本地简化月份名称 %B 本地完整月份名称 %c 本地相应的日期和时间 ...
- 技术文档--volley 框架
Volley 框架 参考文档:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f73e7e808c027fa ...
- [转]编译VC++程序warning C4819快速解决
文章来自:http://www.cppblog.com/API/archive/2012/11/12/195056.aspx 编译VC++程序的时候出现如下提示警告: warning C4819: T ...
- [游戏学习25] MFC 橡皮筋画线效果
>_<:这是给出窗口内外不同情况的处理展示的例子. >_<:MouseCap.h #include<afxwin.h> class CMyApp :public C ...
- dubbo的安装和使用
dubbo的安装和使用
- 算法练习26-xx
26.左旋转字符串(字符串) 题目:定义字符串的左旋转操作:把字符串前面的若干个字符移动到字符串的尾部. 如把字符串abcdef左旋转2位得到字符串cdefab.请实现字符串左旋转的函数.要求时间对长 ...
- bigautocomplete实现联想输入,自动补全
bigautocomplete是一款Jquery插件.用它实现仿搜索引擎文本框自动补全插件功能很实用,使用也很简单,引入了插件之后写几行代码就可以实现,可以灵活设置. 先看效果图: 上图是通过ajax ...