0

Cardview first item

So I follow an Android tutorial from ude*y, everything works perfectly, the only problem is the first and last item of cardview not showing correctly.

Elio Lako
  • 1,333
  • 2
  • 16
  • 26
rizky ramadhan
  • 157
  • 1
  • 2
  • 6

1 Answers1

0

I think you have to margin or padding as your requirement.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"
        tools:context=".MainActivity">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
        <TextView
            android:id="@+id/empty_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableTop="@drawable/tryagain"
            android:gravity="center"
            android:visibility="gone"
            android:text="@string/no_data_available" />
    </RelativeLayout>

</LinearLayout>

You want see more full card view example, please following this github:

https://github.com/dharmakshetri/CardViewExample/blob/master/app/src/main/res/layout/main.xml

and full source code: CardViewExample

Horrorgoogle
  • 7,858
  • 11
  • 48
  • 81