Home > Mobile >  How to change background colour of card view itam?
How to change background colour of card view itam?

Time:09-08

I tried to give the background colour of card view item when they are clicked the colour are set the new activity are open but then back pressed the card item background colour are not set.

if (!arrayListBusinessList.get ( position ).equals ( "" )){
     holder.cardViewBusinessListItem.setCardBackgroundColor ( ContextCompat.getColor ( context,R.color.green ) );
                        lastVisited ( true,position );
}

CodePudding user response:

Try this you can use both color code or color directory path

holder.cardViewBusinessListItem.setBackgroundColor(Color.parseColor("#00FF00"));

CodePudding user response:

Card view has a lot of problems. You should instead change the background of the parent view that is inside card view.

<CardView>
    <RelativeLayout> <-- change this view's background instead
        <ABC.../>
        <XYZ.../>
    </RelativeLayout>
</CardView>
  • Related