java - 检查 ImageView 是否应用了 ColorFilter?
问题描述
所以我正在尝试在我的社交应用程序中点赞,以及是否确定是否已经应用了点赞我试图查看滤色器
因此,如果帖子不受欢迎,它将是白色的,否则我将在按下它的同时执行此行
buttonlikesHeart.setColorFilter(Color.rgb( 255,0,0 ));
这很好用,但是当我想检查它是否已经有这个特定的滤色器时:
if(buttonlikesHeart.getColorFilter() == Color.rgb( 255,0,0 )){
}
它告诉我 == 不能应用于 Colorfilter 和 int ?
如果我这样做
if(buttonlikesHeart.getColorFilter( Color.rgb( 255,0,0 ))){
}
它告诉我 ImageView 中的 getColorFilter 不能应用于 int
解决方案?
解决方案
首先,确保您在 ImageView Not a Button 中应用它。
"buttonlikesHeart" 它应该是一个 ImageView
if(imageView.getColorFilter() == null)
{
Log.i("The Image has no Filter", "No filter");
//Your rest of code here.
}
else
{
Log.i("The Image is Filtered", "Filtered");
//Your rest of code here.
}
推荐阅读
- python - 使用 vs code 运行 pyspark 程序时出现 vscode python 错误
- postgresql - Sequelize 中的排序是否默认为“updateAt”?我可以“不”订购吗?
- php - 简单的会员数据库设计方法
- java - Java 正则表达式中的 \d 和 \\d 有什么区别?
- android - 找不到变量:regeneratorRuntime (ReactNative)
- wpn-xm - Windows 10 更新后 wpn-xm.exe 无法启动
- ckeditor - 在 CKEditor 上显示/隐藏字符
- ffmpeg - ffmpeg 过滤器组合的正确语法?
- c# - AutoMapper 内联忽略
- laravel - 添加 CORS 中间件会删除基于令牌的身份验证