Suppose I have one OR two items in
RecyclerView
. How could I display them in center RecyclerView must have width and height is match_parent
AFAIK recyclerView
starts from top
. How could I give gravity = center
to its single item
. I mean if only 1 item comes it should be in the center of screen.
RecylerView doesn't have gravity attribute
. Is there any other way round.
I can't set it's height to wrap_content. Because I also have to add a swipeRefreshLayout.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/MatchMatch"
android:background="@color/theme_color_gift_finder">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_gift_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/margin_pad_10" />
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/ll_bottom"
style="@style/LinearHorizontal"
android:layout_marginBottom="@dimen/margin_pad_16"
android:background="@android:color/transparent"
android:gravity="center">
<com.netsolace.efc.utility.customviews.widgets.CustomButton
android:id="@+id/btn_go"
android:layout_width="@dimen/circular_go_n_done_btn_size"
android:layout_height="@dimen/circular_go_n_done_btn_size"
android:background="@drawable/oval_generic"
android:text="@string/go"
android:textColor="@color/theme_color_gift_finder"
android:textSize="@dimen/text_size_medium" />
</LinearLayout>
</LinearLayout>
<com.netsolace.efc.utility.customviews.widgets.CustomTextView
android:id="@+id/tv_gift_no_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="No Results"
android:textColor="@android:color/white"
android:textSize="@dimen/text_size_large"
android:textStyle="bold"
android:visibility="gone" />
</FrameLayout>