Cardview shadow not appearing in lollipop devices?

后端 未结 6 1157
北海茫月
北海茫月 2020-12-03 07:05

Am using the cardview in my android app. However the shadow is not showing. Here is the xml layout

The default optionsmenu shadow also not showing.

&         


        
6条回答
  •  日久生厌
    2020-12-03 07:08

    After going through the docs again, I finally found the solution.

    Just add card_view:cardUseCompatPadding="true" to your CardView and shadows will appear on Lollipop devices.

    What happens is, the content area in a CardView take different sizes on pre-lollipop and lollipop devices. So in lollipop devices the shadow is actually covered by the card so its not visible. By adding this attribute the content area remains the same across all devices and the shadow becomes visible.

    My xml code is like :

    
    ...
    
    

提交回复
热议问题