开发者

RelativeLayout TextView overlay

This is my current ListView item layout:

<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:paddingRigh开发者_开发百科t="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 destination TextView overlays the time TextView as you can see on the screen. How to prevent that?

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


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


Use the attribute: android:layout_below="@id/label"

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

You can do following:

  • Use LinearLayout, there you have the attribute orientation.
  • Use RelativeLayout and look into the layout_below attribute


android:ellipsize="end"

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

android:ellipsize="marquee"

and it will scroll like app names in android market. sometimes you have to throw

android:singleLine="true"

in there for it to work, also i would reccomend

android:marqueeRepeatLimit="marquee_forever"

so that it continues moving in case the user missed it the first time.

as seen in Layout Tricks,TextView ellipsize

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜