android开发分享CardView背景颜色始终为白色

我使用GridLayoutManager RecyclerViewՈC;我有kCF;个项目作为CardView。

不幸的是,这里CardView似乎并没有改变它的背景颜色。 我尝试在布局和编程方面,但我已经试过似乎没有工作。

我一直在挣扎了很长时间。 我很感激有人能帮我解决这个问题。

    如果你想改变卡的背景颜色,使用:

    %ignore_pre_1%

    喜欢这个:

     <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" app:cardBackgroundColor="@color/white"> </android.support.v7.widget.CardView> 

    编辑:正如@imposible指出的,你需要包括

     xmlns:app="schemas.android.com/apk/res-auto" 

    在您的根XML标记为了使这个片段function

    您可以使用XML或编程方式执行此操作:

    在XML中:

     card_view:cardBackgroundColor="@android:color/red" 

    编程方式:

    以上就是android开发分享CardView背景颜色始终为白色相关内容,想了解更多android开发(异常处理)及android游戏开发关注(计算机技术网)。

     cardView.setCardBackgroundColor(Color.RED); 

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请点击右边联系管理员删除。

      如若转载,请注明出处:https://www.ctvol.com/addevelopment/512487.html

      (0)
      上一篇 2020年11月27日
      下一篇 2020年11月27日

      精彩推荐