android - RecyclerView within CardView center_vertical -
hello have recyclerview within cardview. want text of recyclerview in center_vertical within cardview.
cardview xml is:
<?xml version="1.0" encoding="utf-8"?> <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="wrap_content"> <android.support.v7.widget.cardview android:id="@+id/item_breakfast" android:layout_width="match_parent" android:layout_height="@dimen/item_breakfast_height" card_view:cardcornerradius="@dimen/item_breakfast_corner"> <relativelayout xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- icon breakfast --> <de.hdodenhof.circleimageview.circleimageview android:id="@+id/breakfast_icon" android:layout_width="@dimen/item_breakfast_circleviewsize" android:layout_height="@dimen/item_breakfast_circleviewsize" android:layout_centervertical="true"/> <android.support.v7.widget.recyclerview android:id="@+id/list_food" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_torightof="@+id/breakfast_icon" android:layout_centerinparent="true" android:scrollbarstyle="insideoverlay"/> </relativelayout> </android.support.v7.widget.cardview> </linearlayout>
the recyclerview xm is:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centervertical="true"> <!-- food --> <textview android:id="@+id/food" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </linearlayout>
the textview id "food" isn't center_vertical. why?
use layout_gravity
center textview
inside layout:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centervertical="true"> <!-- food --> <textview android:id="@+id/food" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" /> </linearlayout>
Comments
Post a Comment