如何通过Adadpter更改FloatingActiobButton(Fab)的背景颜色(How to change the Background color of FloatingActiobBut

编程入门 行业动态 更新时间:2024-10-21 14:23:43
如何通过Adadpter更改FloatingActiobButton(Fab)的背景颜色(How to change the Background color of FloatingActiobButton (Fab) through Adadpter)

我试图通过适配器更改fab按钮的颜色,但不幸的是它只给了我默认的颜色

holder.fab.setBackgroundColor(pojo.getActivity_color());

在我的RecycleView适配器内

pojo = new ParentDashBoard_Pojo("Home Work", R.drawable.ic_book_black_24dp,R.color.dashBoard_parent5); parentDashBoardPojoList.add(pojo);

在我的MainActivity类中

所以R.color.dashBoard_parent5并没有改变fab的颜色

感谢所有建议。

I'm trying to change the color of fab button through adapter but unfortunately it is giving me the default colors only

holder.fab.setBackgroundColor(pojo.getActivity_color());

inside my RecycleView adapter

and

pojo = new ParentDashBoard_Pojo("Home Work", R.drawable.ic_book_black_24dp,R.color.dashBoard_parent5); parentDashBoardPojoList.add(pojo);

Inside my MainActivity class

So the R.color.dashBoard_parent5 is not changing the color of fab

All suggestions are appreciated thanks.

最满意答案

根据我的评论:

使用

holder.fab.setBackgroundTintList(ColorStateList.valueOf(your color in int)); holder.fab.setImageResource(R.mipmap.ic_launcher);

As per my comment :

Use

holder.fab.setBackgroundTintList(ColorStateList.valueOf(your color in int)); holder.fab.setImageResource(R.mipmap.ic_launcher);

更多推荐

本文发布于:2023-08-05 18:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1435756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   背景   Fab   Adadpter   FloatingActiobButton

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!