Playing with Android Support Library v7 widget CardView I see different results on the Galaxy S4 compared to the Nexus 4 device. Having the following layout:
<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_view" android:layout_width="fill_parent" android:layout_height="150dp" android:layout_gravity="center" android:layout_marginTop="8dp" android:layout_marginBottom="10dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:orientation="horizontal" card_view:cardCornerRadius="7dp" card_view:cardElevation="12dp"> <ScrollView android:id="@+id/scrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentStart="true" android:layout_centerVertical="true"> <TextView android:id="@+id/txtExample" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_messages" /> </ScrollView> </android.support.v7.widget.CardView>
I got the following results:
Nexus 4 (5.0.1): 
Samsung Galaxy S4 (4.4.2): 
It seems that the one on Nexus calculates the view with its fields, and then draws a shadow from the outside. On the other hand, one of Samsung seems to apply the margins, and then draws a shadow inside until it reaches the calculated viewing boundaries.
Am I missing something?
GoRoS source share