RelativeLayout TextView наложение - PullRequest
4 голосов
/ 22 мая 2011

Это мой текущий макет элемента ListView:

<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>

Моя проблема заключается в том, что целевой TextView накладывается на время TextView, как вы можете видеть на экране.Как это предотвратить?

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

Ответы [ 3 ]

1 голос
/ 28 мая 2011

Используйте android: layout_toLeftOf = "@ + id / flight_time" в пункте назначения или вы можете установить их оба в TableLayout>

1 голос
/ 18 июня 2011
android:ellipsize="end"

это обрезает текст, если он слишком длинный.или вы можете сделать

android:ellipsize="marquee"

, и он будет прокручиваться как имена приложений в Android Market.иногда вам нужно добавить туда

android:singleLine="true"

, чтобы он работал, также я бы рекомендовал

android:marqueeRepeatLimit="marquee_forever"

, чтобы он продолжал двигаться, если пользователь пропустил его в первый раз.

как видно из Уловки макета , TextView ellipsize

1 голос
/ 22 мая 2011

Используйте атрибут: android: layout_below = "@ id / label"

Вы можете сделать это в одном Relativelayout.И удалите атрибут ориентации из вашего RelativeLayout, он бесполезен.

Вы можете сделать следующее:

  • Использовать LinearLayout, там у вас есть атрибут ориентации.
  • Используйте RelativeLayout и посмотрите на атрибут layout_below
...