Android: Putting eine vertikale divider/separator-Linie zwischen textviews in eine horizontale lineare layout eingebettet in eine vertikale lineare layout?
Für ein android-Inhalte anzeigen, ich habe ein vertikales linearlayout mit einigen textviews, dass einige Linien zu unterteilen und getrennt die vertikalen Elemente, dies funktioniert sehr gut und der xml-Code unten.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/A" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/B" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/C" />
</LinearLayout>
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/D" />
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/E" />
</LinearLayout>
Nun möchte ich hinzufügen, dass eine vertikale Trennlinie zwischen der horizontal Platzierten text Ansichten in der verschachtelten textviews mit strings A/B/C. Wenn ich versuche, so zu tun, indem die hardcoded Breite Ansicht, die Linie erstreckt sich über die gesamte Höhe von der übergeordneten linearen layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/A" />
<!--the vertical line separator-->
<View
android:background="#ffffff"
android:layout_width = "1dip"
android:layout_height="fill_parent" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/B" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="@string/C" />
</LinearLayout>
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/D" />
<View
android:background="#ffffff"
android:layout_width = "fill_parent"
android:layout_height="1dip" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/E" />
</LinearLayout>
Für das vertikale Trennzeichen anzeigen ich habe versucht, zu verwenden android:layout_height="wrap_content"/>
statt, aber das gleiche Ergebnis präsentiert wird.
Gibt es eine Möglichkeit, eine vertikale Trennlinie, die hier, wo die Höhe wird beibehalten, mit der Einführung einer vertikalen Linie trennen textviews? Oder muss ich ein anderes layout auszuwählen?
InformationsquelleAutor Vass | 2012-10-10
Du musst angemeldet sein, um einen Kommentar abzugeben.
Einer anderen option kann zu zählen
android:layout_margin
(oder separatelayout_marginTop
undlayout_marginBottom
), einen Raum zu schaffen zwischen oben und unten in die gezeichnete vertikale Linie, und die jeweiligen horizontalen Kanten derLinearLayout.
Andere als das, ich könnte versuchen, eine
RelativeLayout,
und Ihre vertikale Linie anzeigen angepasst zu ausrichten, oben und unten an einer der angrenzendenTextViews.
InformationsquelleAutor Mark Semsel
Haben Sie eine fix-Höhe entweder zu Ihrem LinearLayout oder Ihre Vertikalen Seperator
InformationsquelleAutor maninder singh