Drawable as Background for CardView

后端 未结 11 973
傲寒
傲寒 2020-12-08 02:29

the CardView ( android.support.v7.cardview ) stays white even though I set a backround drawable via android:backround - The documentation gives me the feeling that it should

11条回答
  •  不思量自难忘°
    2020-12-08 02:41

    The command I used was:

    cardView.setBackgroundResource(R.drawable.card_view_bg);
    

    where card_view_bg is a custom XML resource file.

    If you have some layouts inside the card view and these layouts are overlapping with the margins of the card view then you might need a separate custom background resource file for the layouts like the one I used for the card view background itself.

提交回复
热议问题