Drawable as Background for CardView

后端 未结 11 999
傲寒
傲寒 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:55

    You have 2 possible solutions.

    1. Setting background programmatically:
    cardView.setBackgroundResource(R.drawable.background)
    
    1. Add some child to cardview that will fill cardview's bounds and set background on it:
    
         
    
    

    This way you can also give images some shape that you can configure by the shape of cardview. Disadvantage is that it is bad for performance.

提交回复
热议问题