CardView has extra margin in each edge on Pre-Lollipop

前端 未结 7 863
闹比i
闹比i 2020-12-24 14:05

Here are two pictures.

on Lollipop: \"on

on Pre-Lollipop:

7条回答
  •  粉色の甜心
    2020-12-24 14:30

    Before L, CardView adds padding to its content and draws shadows to that area. This padding amount is equal to maxCardElevation + (1 - cos45) * cornerRadius on the sides and maxCardElevation * 1.5 + (1 - cos45) * cornerRadius on top and bottom.

    From the CardView reference here

    Try setting a negative left margin on the CardView like this

    
    

    You may need to adjust the margin to get the desired result.

    PS, this is kind of a hack-y way to do it.

提交回复
热议问题