Guten Tag! Ich versuche eine bestimmte Art von Layout zu erreichen. Ich hoffe, jemand könnte mir einen Hinweis geben, wie es richtig gemacht wird.TextView in LinearLayout von einem anderen TextView geschoben
Also, in meinem Layout habe ich zwei TextView innerhalb eines LinearLayout mit horizontaler Ausrichtung. Die erste TextView enthält den Namen der Firma und die zweite enthält eine Anzahl der damit verbundenen Projekte.
wollte ich mein Layout wie this.
Mein aktuelles Layout wie this sieht verhalten.
Hier ist der spezifische Code für das Layout:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/contractor_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Gem Seeker Company and Supplies in"
android:textColor="@color/list_title"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(0)"
android:textSize="16sp"
android:textStyle="bold"
android:maxLines="1"
android:layout_marginStart="4dp"
android:textColor="@color/space_gray_01"/>
</LinearLayout>
Heres der vollständige Code des Layouts:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="@android:color/white"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/contractor_item_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:orientation="horizontal">
<ImageView
android:id="@+id/contractor_item_avatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@color/space_gray_01"
android:contentDescription="@string/image_description"
android:src="@drawable/ic_user_light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/contractor_item_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/contractor_item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Gem Seeker Company and Supplies in"
android:textColor="@color/list_title"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(0)"
android:textSize="16sp"
android:textStyle="bold"
android:maxLines="1"
android:layout_marginStart="4dp"
android:textColor="@color/space_gray_01"/>
</LinearLayout>
<TextView
android:id="@+id/contractor_item_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/text_no_address"
android:textColor="@color/list_subtitle"
android:textSize="14sp" />
<TextView
android:id="@+id/contractor_item_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/text_no_contact"
android:textColor="@color/list_subtitle"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/contractor_item_show"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:contentDescription="@string/image_description"
android:src="@drawable/ic_show"
android:tint="@color/space_gray_02" />
</LinearLayout>
zu verteilen Versuchen layout_weight = 1 bis Anzahl des Projektes einstellen Textview – Arthur
Verwenden Sie relatives Layout Stattdessen oder besser Constraintlayout als Stammeltern. – krishan