CollapsingToolbarLayout crash on 4.4 devices (java.lang.IllegalArgumentException: radius must be > 0)

后端 未结 5 1607
醉梦人生
醉梦人生 2021-02-05 14:54

I have implemented the new style Collapsible Toolbar. I am using the same code as the example (Cheesesquare) demo app - which of course works fine on all devices. I need help

5条回答
  •  Happy的楠姐
    2021-02-05 15:53

    According to CardView's Doc:

    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.

    Since padding is used to offset content for shadows, you cannot set padding on CardView. Instead, you can use content padding attributes in XML or setContentPadding(int, int, int, int) in code to set the padding between the edges of the Card and children of CardView.

    Check all wrap-parent values. I think some where in your code is changing this padding behavior which caused mCornerRadius < 0 in buildShadowCorners method in RoundRectDrawableWithShadow.java.

    These links maybe help:

    width and height must be > 0 error

    Android CardView padding and minHeight

    CardView inside RecyclerView has extra margins

提交回复
热议问题