如何通过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);更多推荐
发布评论