/ / Zeige zwei Textfelder vertikal (untereinander in der Listenansicht) - Android, Android-Layout

Zeige zwei Textfelder vertikal (untereinander in der Listenansicht) - Android, Android-Layout

Bildbeschreibung hier eingeben

Ich möchte das Textfeld Dauer unterhalb anzeigenTextfeld Item.Ich habe die Listenansicht, die für gerade und ungerade Zeilen unterschiedlich ausgefüllt ist. Aber die Sache ist, ich möchte das zwei Textfeld parallel zum Bild, das ich vertikal anzeigen möchte, aber wenn ich das zwei Textfeld in das vertikale Liner-Layout einfüge, zeigt es einen Fehler an. So zeigen Sie das zwei Textfeld vertikal an. Entschuldigung, wenn irgendein Fehler in meinem Englisch. Danke im Voraus.

Unten ist mein Code:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="@string/app_name"
android:src="@drawable/male" />
<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />
<TextView
android:id="@+id/name1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_light" />
</LinearLayout>

Antworten:

2 für die Antwort № 1

benutze das ->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="@string/app_name"
android:src="@drawable/male" />

<LinearLayout
android:layout_weight="60.5"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent">

<TextView
android:id="@+id/name"
android:text="asdasdas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />
<TextView
android:id="@+id/name1"
android:text="asdasd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_light" />

</LinearLayout>

</LinearLayout>

3 für die Antwort № 2
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="@string/app_name"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />
<TextView
android:id="@+id/name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_light" />
</LinearLayout>

Versuche dies!!! Es wird den Blick darauf geben, was Sie suchen.


3 für die Antwort № 3

Bitte überprüfen sie unten meine code hier ich verwalten ihre beide verschiedenen artikel anzeigen in einzelnen layout, so haben sie nur zeigen / verbergen entsprechende layout basierend auf artikel:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">

<LinearLayout
android:id="@+id/male_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/gender_image_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/app_name"
android:src="@drawable/male" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/name_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />

<TextView
android:id="@+id/name1_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/holo_green_light" />
</LinearLayout>

</LinearLayout>

<LinearLayout
android:id="@+id/female_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/gender_image_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/app_name"
android:src="@drawable/female" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:id="@+id/name_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />

<TextView
android:id="@+id/name1_female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/holo_green_light" />
</LinearLayout>

</LinearLayout>
</LinearLayout>

Hinweis : android:layout_weight wird benutzt Rest des Gebiets nehmen.


2 für die Antwort № 4
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/gender_image"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="39.5"
android:contentDescription="@string/app_name"
android:src="@drawable/male"  />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:textColor="@android:color/holo_green_dark" />
<TextView
android:id="@+id/name1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"

android:textColor="@android:color/holo_green_light" />
</LinearLayout>

</LinearLayout>

PS: setze die Gewichte und die Breite entsprechend ... :)