Android ListView card behaviour -
i noticed something. when use layout inside listview use linearlayout cardview inside it. cardview has margin of 10dp , looks fine. however, when use cardview has same attributes, not give me margin @ all. there i'm doing wrong?
layout 1 (gives me layout want):
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.cardview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" card_view:cardbackgroundcolor="@color/white" card_view:cardelevation="2sp" card_view:cardusecompatpadding="true"> </android.support.v7.widget.cardview> </linearlayout>
layout 2 (without margin):
<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:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="10dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" card_view:cardelevation="2sp" card_view:cardusecompatpadding="true" card_view:cardbackgroundcolor="@color/white"> </android.support.v7.widget.cardview>
i ran problem. think happens, because listview ignores/doesn't support margin attribute.
more this: why linearlayout's margin being ignored if used listview row view
a note on side: use framelayout around cardview, better performance-wise.
Comments
Post a Comment