Use the vertical line in the ListView.

I am trying to show a vertical line in an android ListView element. I define it in XML for the cell, but when I view it in the ListView, it does not appear.

I understand that this is a problem, because here I see a lot of questions, but I do not see a real answer.

XML is pretty standard:

Cell:

<?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="match_parent"
  android:background="@color/appWhite" >

  <View android:layout_width="5dp"
      android:layout_height="match_parent"
      android:background="@color/appGreen"
      android:layout_alignParentLeft="true" />

  <RelativeLayout
      android:id="@+id/cell_trip_info_container"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toRightOf="@+id/vertical_bar" >

    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cell_trip_name"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:textColor="#2c3e50"
        android:paddingLeft="10dp"
        android:text="adfadf" />
    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cell_trip_country"
        android:layout_below="@+id/cell_trip_name"
        android:textColor="#2c3e50"
        android:paddingLeft="10dp"
        android:text="adfadf" />
  </RelativeLayout>

  <RelativeLayout android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:id="@+id/whole_container"
    android:layout_alignParentRight="true" >

    <RelativeLayout android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:background="@color/appGreen"
      android:id="@+id/cell_trip_date_box"
      android:layout_alignTop="@+id/update_buttons"
      android:layout_alignBottom="@+id/update_buttons"
      android:padding="20dp" >

      <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cell_tripstart_date"
        android:layout_centerHorizontal="true"
        android:textColor="#fff" />
      <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cell_date_thru"
        android:text="@string/thru"
        android:layout_below="@+id/cell_tripstart_date"
        android:layout_centerHorizontal="true"
        android:textColor="#fff" />
      <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cell_tripend_date"
        android:layout_below="@+id/cell_date_thru"
        android:textColor="#fff"
        android:layout_centerHorizontal="true" />

    </RelativeLayout>    

    <RelativeLayout android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:id="@+id/update_buttons"
      android:visibility="gone"
      android:layout_toRightOf="@+id/cell_trip_date_box"
      android:background="#e9e9e9"
      android:padding="20dp" >

      <ImageView android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/cell_button_edit_trip"
        android:src="@drawable/slide_edit"
        android:adjustViewBounds="true"
        android:contentDescription="@string/content_description" />

      <ImageView android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/cell_button_delete_trip"
        android:src="@drawable/slide_delete"
        android:layout_toRightOf="@+id/cell_button_edit_trip"
        android:adjustViewBounds="true"
        android:contentDescription="@string/content_description" />

    </RelativeLayout>   
  </RelativeLayout>
</RelativeLayout>
+4
source share
3 answers

I found the reason and the obvious solution / workaround for another post here

RelativeLayouts - "match_parent" ListView. LinearLayout. LinearLayout. RelativeLayout .

, .

+3

cell_trip_info_container RelativeLayout

android:layout_toRightOf="@+id/vertical_bar"

View vertical_bar

,

<View
      android:id="@+id/vertical_bar"
      android:layout_width="5dp"
      android:layout_height="match_parent"
      android:background="@color/appGreen"
      android:layout_alignParentLeft="true"  />
0

RelativeLayout VerticalLayout

-2

All Articles