Layout Validation different to Load program android Studio

Viewed 822

Comparison of code, Final result and Layout Validation

I'm trying to generate a Button on the bottom of the Screen, First I use a linear layout for the other elements of the data recollecting program, it uses two other layouts to generate an auto-sizing list, everything is working well with exception of the last button that appears in the Layout Validation but when I run it, it disappears.

enter code here
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="false">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/linearLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal"
            android:weightSum="10">

            <LinearLayout
                android:id="@+id/ly1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="9"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txN1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margeny_1"
                    android:text="@string/nombre"
                    android:textColor="@color/primary_text"
                    android:textSize="@dimen/texto_2" />

                <EditText
                    android:id="@+id/txN2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:autofillHints="username"
                    android:background="@color/divider"
                    android:inputType="text"
                    android:textColor="@color/secondary_text"
                    android:textSize="@dimen/textos_1" />

                <TextView
                    android:id="@+id/txf1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margeny_1"
                    android:text="@string/fecha"
                    android:textColor="@color/primary_text"
                    android:textSize="@dimen/texto_2" />

                <TextView
                    android:id="@+id/txf2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/divider"
                    android:textColor="@color/secondary_text"
                    android:textSize="@dimen/textos_1" />

                <Button
                    android:id="@+id/btf1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margeny_2"
                    android:text="@string/deffecha"
                    android:theme="@style/Button1" />

                <TextView
                    android:id="@+id/txT1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margeny_1"
                    android:text="@string/telefono"
                    android:textColor="@color/primary_text"
                    android:textSize="@dimen/texto_2" />

                <EditText
                    android:id="@+id/edT1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:autofillHints="Phone"
                    android:background="@color/divider"
                    android:inputType="phone"
                    android:textColor="@color/secondary_text"
                    android:textSize="@dimen/textos_1" />

                <TextView
                    android:id="@+id/txE1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/email"
                    android:textColor="@color/primary_text"
                    android:textSize="@dimen/texto_2" />

                <EditText
                    android:id="@+id/edE1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/divider"
                    android:inputType="textEmailAddress"
                    android:textColor="@color/secondary_text"
                    android:textSize="@dimen/textos_1" />

                <TextView
                    android:id="@+id/txDC1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/descripcion"
                    android:textColor="@color/primary_text"
                    android:textSize="@dimen/texto_2" />

                <EditText
                    android:id="@+id/edDC1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:autoSizeTextType="uniform"
                    android:background="@color/divider"
                    android:inputType="text"
                    android:textColor="@color/secondary_text"
                    android:textSize="@dimen/textos_1" />
            </LinearLayout>
        </LinearLayout>

        <Button
            android:id="@+id/btSig"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="0dp"
            android:baselineAligned="false"
            android:text="Siguiente"
            android:theme="@style/Button1"
            app:layout_constraintBottom_toBottomOf="@+id/linearLayout"
            />
    </LinearLayout>
1 Answers

I don't know why and how You want to auto-resize content but I make something like this:

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/btSig"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <TextView
                android:id="@+id/txN1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="nombre" />

            <EditText
                android:id="@+id/txN2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="username"
                android:inputType="text" />

            <TextView
                android:id="@+id/txf1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="fecha" />

            <TextView
                android:id="@+id/txf2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="4" />

            <Button
                android:id="@+id/btf1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="deffecha" />

            <TextView
                android:id="@+id/txT1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="telefono" />

            <EditText
                android:id="@+id/edT1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autofillHints="Phone"
                android:inputType="phone" />

            <TextView
                android:id="@+id/txE1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="email" />

            <EditText
                android:id="@+id/edE1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress" />

            <TextView
                android:id="@+id/txDC1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <EditText
                android:id="@+id/edDC1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:autoSizeTextType="uniform"
                android:inputType="text" />

        </LinearLayout>

    </ScrollView>

    <Button
        android:id="@+id/btSig"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:text="Siguiente"
        app:layout_constraintBottom_toBottomOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

(Of course, I change strings and dimension values)

It looks like that:

enter image description here

One button is always on the bottom of the screen and the rest in scroll view.

Related