Cardview And Recyclerview Divider Behaviour
Solution 1:
The spaces you can see are compat paddings and they're visible only on pre-Lollipop devices (or everywhere if you set card_view:cardUseCompatPadding="true"
). You can find values here (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.
Also, as far as I can see, there is some default radius for CardView
's corner (probably it is 2dp).
You can try any tricks to avoid these spaces or (IMHO it's better) consider if you should make view with custom background, like simple "tile". Here you have some info from Google about design.
Solution 2:
That's the default behavior of CardView
, however you can modify how it should look, like removing the border radius and etc by adding attributes to your CardView
declaration.
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp"
card_view:cardBackgroundColor='#ffffff'>
For more information must visit this to clip shadows https://developer.android.com/training/material/shadows-clipping.htmlhttps://developer.android.com/reference/android/support/v7/widget/CardView.html
Solution 3:
Try this layout
<android.support.v7.widget.CardViewandroid:layout_width="match_parent"android:layout_height="match_parent"><RelativeLayoutandroid:layout_width="100dp"android:layout_height="100dp"android:layout_gravity="center"android:gravity="center"><ImageViewandroid:id="@+id/image_view"android:src="@drawable/androidsss"android:layout_width="50dp"android:layout_height="50dp"android:layout_alignParentTop="true"android:layout_centerInParent="true" /><TextViewandroid:id="@+id/info_text"android:layout_below="@+id/image_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_centerInParent="true"android:gravity="center"android:ellipsize="end"android:singleLine="true"android:textColor="@android:color/black"android:textSize="14sp" /></RelativeLayout></android.support.v7.widget.CardView></LinearLayout>
Post a Comment for "Cardview And Recyclerview Divider Behaviour"