简体   繁体   English

如何更改卡片视图itam的背景颜色?

[英]How to change background colour of card view itam?

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 );
}

Try this you can use both color code or color directory path试试这个,你可以同时使用颜色代码或颜色目录路径

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

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM