user4579047
user4579047

Reputation: 103

horizontal listview with custom listview item not displaying views

I am having a custom listview where each item is displaying a sequence of textview followed by imageview followed by textview and so on in horizontal manner like this:

text1->text2->text3->text4

->is depicting an imageview. While displaying data,some of the views at the right end of screen are not getting displayed and the last displaying item is getting smaller in size.How can I make the rest of the items come down on the next line?Please help..

I tried using RelativeLayout as well as LinearLayout with horizontal orientation.Here is the code for single list item

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="home.example.com.homeapp.UIclass.plusConnectSingleListItem"
>

<ImageView
    android:id="@+id/bigArrowImageView"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:background="@drawable/ic_big_arrow"
    />

<TextView
    android:id="@+id/textView1"
    android:layout_toRightOf="@id/bigArrowImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person1"
    />

<ImageView
    android:id="@+id/arrow1ImageView"
    android:layout_toRightOf="@id/textView1"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:background="@drawable/ic_arrow"
    />

<TextView
    android:id="@+id/textView2"
    android:layout_toRightOf="@id/arrow1ImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person2"
    />


<ImageView
    android:id="@+id/arrow2ImageView"
    android:layout_toRightOf="@id/textView2"
    android:layout_width="30dp"
    android:layout_height="30dp"
    />

<TextView
    android:id="@+id/textView3"
    android:layout_toRightOf="@id/arrow2ImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person3"
    />

<ImageView
    android:id="@+id/arrow3ImageView"
    android:layout_toRightOf="@id/textView3"
    android:layout_width="30dp"
    android:layout_height="30dp"
    />

<TextView
    android:id="@+id/textView4"
    android:layout_toRightOf="@id/arrow3ImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person4"
    />

<ImageView
    android:id="@+id/arrow4ImageView"
    android:layout_toRightOf="@id/textView4"
    android:layout_width="30dp"
    android:layout_height="30dp"
    />

<TextView
    android:id="@+id/textView5"
    android:layout_toRightOf="@id/arrow4ImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person5"
    />

<ImageView
    android:id="@+id/arrow5ImageView"
    android:layout_toRightOf="@id/textView5"
    android:layout_width="30dp"
    android:layout_height="30dp"
    />

<TextView
    android:id="@+id/textView6"
    android:layout_toRightOf="@id/arrow5ImageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Person6"
    />

Upvotes: 1

Views: 108

Answers (2)

Deven Singh
Deven Singh

Reputation: 418

use LinearLayout with horizontal orientation and give weight each child element of linear layout according to your need...If you don't need textView wrap their content then specify singleLine="true" to textView..

Upvotes: 0

Selva kumar
Selva kumar

Reputation: 13

Set the width size 100% for the list parent container

Upvotes: 0

Related Questions