RelativeLayout TextView Overlay

This is my current ListView item:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="6dp" android:paddingRight="6dp" android:paddingBottom="6dp"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="6dp"> <TextView android:id="@+id/departure_line" android:layout_width="wrap_content" android:layout_height="fill_parent" android:singleLine="true" android:textSize="16sp" android:textStyle="bold" android:shadowColor="#000000" android:shadowDx="1" android:shadowDy="1" android:shadowRadius="1" android:paddingLeft="3dp" android:paddingRight="3dp" /> </RelativeLayout> <TextView android:id="@+id/departure_destination" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_marginLeft="52dp" android:background="#777777" android:singleLine="true" android:ellipsize="end" android:textSize="16sp" /> <TextView android:id="@+id/departure_time" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:textSize="16sp" /> </RelativeLayout> 

My problem is that the target TextView overlays the TextView time, as you can see on the screen. How to prevent this?

http://www.abload.de/image.php?img=screensk6y.png

+4
source share
3 answers

Use android: layout_toLeftOf = "@ + id / departure_time" at your destination or you can set them both in TableLayout>

+1
source

Use attribute: android: layout_below = "@ identifier / label"

You can do it in one Relativelayout. And remove the orientation attribute from RelativeLayout, it is useless.

You can do the following:

  • Use LinearLayout, there you have the attribute orientation.
  • Use RelativeLayout and examine the layout_below attribute
+1
source
 android:ellipsize="end" 

this will shorten the text if it is too long. or you can do

 android:ellipsize="marquee" 

and it will scroll like the names of the applications on the Android market. sometimes you need to quit

 android:singleLine="true" 

there for it to work, I would also recommend

 android:marqueeRepeatLimit="marquee_forever" 

so that it continues to move if the user missed it for the first time.

as shown in Layout Tricks , TextView ellipsize

+1
source

All Articles