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\ ...
随机推荐
- Linux部署apache
一.我们使用源码安装 官网:https://httpd.apache.org/文档:https://httpd.apache.org/docs/2.4/ 下载源码包 httpd-2.4.20.tar. ...
- Linux 查杀进程
ps -eaf |grep "stoporder.php" | grep -v "grep"| awk '{print $2}'|xargs kill -9 # ...
- 玩转React样式
很久很久以前,就有人用CSS来时给HTML内容添加样式.CSS可以最大限度的分离样式和内容,选择器也可以很方便的给某些元素添加样式.你根本找不到任何不用CSS的理由. 但是在React这里就是另外一回 ...
- 【Android开发】 第一课 环境搭建教程
Windows 开发环境部署: Android Studio 中文社区:http://www.android-studio.org/ 本教程将分为五个步骤来完成Android开发环境的部署. 第一步: ...
- 我总结的Android编程规范
命名规则 1). 类名,接口名:以大写开头,如果一个类的类名由多个单词组成,所有单词的首字母必须大写,单词尽量写全称,不要简写,除非约定俗成的名字,例如:URL,RTMP,RTSP 这些广泛使用的专有 ...
- 手机数据抓包以及wireshark技巧
本文主要讨论一种非常方便的抓取Android和iphone手机网络数据包的办法,以及介绍wireshark最常用的技巧 抓包工具介绍 (1).网页抓包工具 Chrome浏览器插件 FireBug 插件 ...
- [转]15年双11手淘前端技术巡演 - H5性能最佳实践
[原文地址]:https://github.com/amfe/article/issues/21 前言 2015年是全面『无线化』的一年,在BAT(财报)几家公司都已经超过50%的流量来自移动端,这次 ...
- Web服务器优化
系统 1. 修改远程默认端口 2. Raid5 3. IIS 1. 默认文档,仅保留一个有效的. 2. 数据库 1. 更改默认端口 2. 如果一台服务器,禁用网络登录
- jboss7(01)服务器开启和关闭命令
1.简单开启服务器的命令:进入到 bin 目录下,输入 ./standalone.sh 命令. 这种开启服务器的方式有个缺点,当你的命令窗口关闭后,服务自动down了 2.让服务器开启后在后台运行:进 ...
- 在Github上注册账户
首先打开网址:https://github.com/ 进行注册 注册完成后进入邮箱验证 在右上角创建一个简单的项目仓库 创建完成