Android - Возможно ли создать несколько TextInputEditText из одного TextInputLayout? - PullRequest
0 голосов
/ 12 января 2020

У меня есть макет. Xml (фрагмент):


<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <TextView
        android:id="@+id/text_titulo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="1dp"
        android:text="Patologias"
        android:textAlignment="center"
        android:textSize="20sp"
        app:layout_constraintBottom_toTopOf="@+id/scrollView2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginStart="1dp"
        android:layout_marginTop="50dp"
        android:layout_marginEnd="1dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/text_titulo">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:hintTextColor="@color/colorPrimary"
                android:textColorHint="@color/colorPrimary"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                app:boxCornerRadiusTopStart="8dp"
                app:boxCornerRadiusTopEnd="8dp"
                app:boxCornerRadiusBottomEnd="8dp"
                app:boxCornerRadiusBottomStart="8dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Nome da doença"/>

            </com.google.android.material.textfield.TextInputLayout>
        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

И мне нужно сгенерировать 5 TextInputEditText, но, когда я попробовал «гнездо», последовательность TextInputEditText не работает, работает только первый объявленный .

В основном мне это нужно:

Example

Извините за мой плохой английский sh и объяснение, если мой вопрос очень перепутал, предложил редактировать для меня.

...