Android 5.0 does not respect view's margins

118 views Asked by At

I have an app that runs well in any version of android, but in Lollipop seems that all views don't respect any margin or padding. Does anyone know why??

Thanks in advance.

I'm declaring the CardView like this:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view1"
android:background="@color/backgroundItem"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_marginRight="2dp"
android:layout_marginLeft="2dp"
card_view:cardCornerRadius="0dp"
android:layout_weight="1">
1

There are 1 answers

1
ianhanniballake On

Per the CardView documentation:

Note that, if you specify exact dimensions for the CardView, because of the shadows, its content area will be different between platforms before L and after L. By using api version specific resource values, you can avoid these changes. Alternatively, If you want CardView to add inner padding on platforms L and after as well, you can set setUseCompatPadding(boolean) to true.