Ich versuche, das folgende Layout zu erreichen:Textview mit langen Text schiebt andere Ansichten außerhalb des Bildschirms
+----------------------------------------+
| [icon] [text] [icon] |
+----------------------------------------+
| [icon] [very loooooooooooooooooo [icon]|
| oooooooooooooooong text] |
+----------------------------------------+
Wenn der Text kurz ist, wird das Symbol auf der rechten Seite muss direkt neben dem Text sein (nicht richtig ausgerichtet). Wenn der Text lang ist, muss der Text umbrochen werden.
Ich habe versucht, LinearLayout und RelativeLayout zu verwenden, aber die Symbole werden immer noch ausgeschoben, wenn ich einen langen Text habe. Hier sind die Layouts ich versucht habe:
Linearlayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="left"/>
<TextView
android:id="@+id/middle"
android:text="a long long string, a long long string, a long long string, a long long string, a long long string, a long long string, "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#D0E198"/>
<TextView
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="right"/>
</LinearLayout>
RelativeLayout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="left"/>
<TextView
android:id="@+id/middle"
android:text="a long long string, a long long string, a long long string, a long long string, a long long string, a long long string, "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#D0E198"
android:layout_toRightOf="@id/left"/>
<TextView
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="right"
android:layout_toRightOf="@id/middle"/>
</RelativeLayout>
In beiden Fällen das richtige Symbol wird aus dem Bildschirm geschoben.
Ich habe auch LinearLayout mit layout_weight = "1" in der linken und rechten Ansicht und 0 in der mittleren Ansicht versucht. Das schiebt beide Symbole vom Bildschirm.
Danke für den Vorschlag. Ich habe es versucht. Aber ich möchte nicht, dass das Symbol richtig ausgerichtet ist. Es muss direkt neben dem Textfeld sein, wenn das Textfeld kurz ist. Ich habe meine Frage aktualisiert, um dies zu klären. – Comtaler