country_row.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="1dp" android:paddingEnd="10dp" android:paddingLeft="5dp" android:paddingRight="10dp" android:paddingStart="10dp" android:paddingTop="5dp"> <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" app:cardCornerRadius="5dp" app:cardElevation="3dp" app:cardUseCompatPadding="true" app:contentPadding="10dp"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/imageViewCountry" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:contentDescription="image" app:srcCompat="@mipmap/iran" /> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_marginLeft="10dp" android:layout_marginStart="10dp" android:layout_toEndOf="@+id/imageViewCountry" android:layout_toRightOf="@+id/imageViewCountry" android:orientation="vertical"> <TextView android:id="@+id/textViewCountryName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Country" android:textAppearance="@android:style/TextAppearance.Large" /> <TextView android:id="@+id/textViewCountryCapital" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Capital" /> </LinearLayout> </RelativeLayout> </android.support.v7.widget.CardView> </RelativeLayout>
References
https://github.com/mhdr/AndroidSamples/tree/master/085
https://pupli.net/2017/05/21/android-working-with-recyclerview-and-cardview/
https://developer.android.com/training/material/lists-cards.html
https://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android–cms-23465
http://www.androidhive.info/2016/05/android-working-with-card-view-and-recycler-view/
http://stackoverflow.com/questions/27599603/cardview-not-showing-shadow-in-android-l
https://www.youtube.com/watch?v=A2_6mI7drVQ