CardView not showing Shadow in Android L

前端 未结 17 933
一生所求
一生所求 2020-11-28 02:50

My Cardview inside Listview is not showing shadow in Android L(Nexus 5). Also the round edges are not properly shown. Here is the code for Listview\'s Adapter View :

17条回答
  •  时光取名叫无心
    2020-11-28 03:11

    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 :

    
    ...
    
    

提交回复
热议问题