I have a listview
with a custom adapter in which I have 3 textview
s, two are next to each other and one is below the others. The problem I am running into though, is when the first textview
extends, it pushes the other textview
off the screen.
I have not been able to successfully get this to work, here is an example of what's happening:
As you can see when the first textview
gets too long, it then pushes the other text off the screen. I would like it so it wraps but the date textview
is also showing. It should also be functional in horizontal view.
Here's the listview
adapter code:
<RelativeLayout android:id="@+id/vw1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:descendantFocusability="blocksDescendants" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/liName" android:textSize="17sp"
android:textColor="#333" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="left"
android:layout_gravity="left" />
<TextView android:id="@+id/liDate" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="right"
android:layout_gravity="right" android:width="60sp" android:layout_toRightOf="@+id/liName" />
<TextView android:id="@+id/liNum" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@+id/liName" />
</RelativeLayout>
I am assuming that the text view being pushed is the liDate one. You need to put this one before the liName in your layout and set the width to "wrap_content" and align it right. Then you lace the liName to the left of it with "fill_parent" width So it would look like this:
<RelativeLayout android:id="@+id/vw1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:descendantFocusability="blocksDescendants" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/liDate" android:textSize="12sp"
android:textColor="#666" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:width="60sp"
android:layout_alignParentRight="true" />
<TextView android:id="@+id/liName" android:textSize="17sp"
android:textColor="#333" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/liDate" />
<TextView android:id="@+id/liNum" android:textSize="12sp"
android:textColor="#666" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@+id/liName" />
Hope this is what you meant