I have item for RecyclerView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginRight="@dimen/default_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/item_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/deviders_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true">
<View
android:layout_weight="1"
android:background="@color/divider"
android:layout_marginLeft="@dimen/bonus_circle_line_padding"
android:layout_height="match_parent"
android:layout_width="1dp"
android:id="@+id/devider_top" />
<View
android:layout_weight="1"
android:background="@color/divider"
android:layout_marginLeft="@dimen/bonus_circle_line_padding"
android:layout_height="match_parent"
android:layout_width="1dp"
android:id="@+id/devider_bottom" />
</LinearLayout>
<RelativeLayout
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<bank.ui.view.FlexibleСircleText
android:id="@+id/value_text"
android:layout_width="@dimen/bonus_circle_text_max_diameter"
android:layout_height="@dimen/bonus_circle_text_max_diameter"/>
<LinearLayout
android:orientation="vertical"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginRight="@dimen/default_padding"
android:layout_width="match_parent"
android:minHeight="@dimen/bonus_circle_text_max_diameter"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/value_text"
android:layout_toEndOf="@+id/value_text"
android:id="@+id/linearLayout2">
<TextView
android:textSize="@dimen/font_size_standard"
android:text="text"
android:id="@+id/text"
android:layout_marginBottom="2dp"
android:gravity="bottom"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:textColor="@color/text_grey"
android:textSize="@dimen/font_size_small"
android:text="text"
android:id="@+id/amount"
android:layout_marginTop="2dp"
android:gravity="top"
android:layout_weight="1"
android:ellipsize="end"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
Item have normal size for all elements, but layout with id "deviders_layout" size always have height = 0;
I tried add
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
to layout with id "deviders_layout". This is not working for me.
Design
RelativeLayout
with id item_layout
has height set to wrap_content
, it has 2 child layouts :
A RelativeLayout
with height set to wrap_content
and a content which has a not null height
A LinearLayout
with id deviders_layout
has height set to match_parent
and content that is also set to match_parent
. With this configuration your layout will always be "flat", you either need to give content a height and use wrap_content
or set parent s height to match_parent
try this :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
android:paddingLeft="10dp">
<TextView
android:id="@+id/value_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="16dp"
android:background="@drawable/txt_shape_bg"
android:padding="10dp"
android:text="200" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/value_text"
android:layout_marginLeft="20dp"
android:layout_marginTop="0.5dp"
android:background="@color/play_game_controls_background_color"
android:paddingLeft="1dp">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#ffffff"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="10dp">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:layout_weight="1"
android:gravity="bottom"
android:text="This is Base text"
android:textSize="18sp" />
<TextView
android:id="@+id/amount"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="top"
android:text="200 Childs "
android:textColor="@color/pink"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
background xml shape for text view :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<corners android:radius="10dip"/>
<stroke android:color="#FF0000" android:width="5dip"/>
<solid android:color="#FF0000"/>
</shape>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.