Search code examples
androidfloating-action-button

How to change the Background color of FloatingActiobButton (Fab) through Adadpter


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.


Solution

  • As per my comment :

    Use

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