CardView elevation not working on Android 5.1.1

前端 未结 5 1587
面向向阳花
面向向阳花 2021-01-01 07:18

I am using CardView inside a RecyclerView. After reading a lot I ended up with following \'NOT WORKING\' code only on Android 5.1.1. On Android Version prior to this one its

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-01 07:39

    Just simply add this code to your Card View in xml file!

        card_view:cardUseCompatPadding="true"
    

    You have to import card_view with Alt+Enter ! And code below will be import in top !.

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

    You'll see elevation is working on android 5 or 5+ .

提交回复
热议问题