why constrainlayout not showing exactly as real device - android

I am developing new app but my preview window showing different and real device different I did not understand what is the problem
below my current layout
<?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:background="#451C80">
<TextView
android:id="#+id/getStarted"
style="#style/password"
android:layout_width="178dp"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginEnd="148dp"
android:gravity="center"
android:text="#string/password"
android:textAppearance="#style/password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="34dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="11dp"
android:src="#drawable/ic_back"
app:layout_constraintEnd_toStartOf="#+id/getStarted"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView"
style="#style/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="55dp"
android:layout_marginTop="138dp"
android:layout_marginEnd="220dp"
android:layout_marginBottom="32dp"
android:text="#string/set_password"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="#id/textInputLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView3"
style="#style/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:text="Confirm Password"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="#+id/textInputLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.167"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="318dp"
android:layout_height="44dp"
android:layout_marginTop="192dp"
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/editText3"
android:layout_width="318dp"
android:layout_height="44dp"
android:background="#drawable/username_edittext"
android:inputType="textPassword"
tools:ignore="TouchTargetSizeCheck" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout2"
android:layout_width="318dp"
android:layout_height="44dp"
android:layout_marginBottom="506dp"
app:endIconMode="password_toggle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.494"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="316dp"
android:layout_height="47dp"
android:layout_marginStart="1dp"
android:background="#drawable/username_edittext"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
current screen from preview window in android studio
screenshot from real device
I want to know exactly where I am making mistake what I am making wrong what I have to do in order to implement correctly constrainlayout

You have not given constraints properly.
Don't use this property layout_constraintHorizontal_bias to arrange views, understandlayout_constraintTop_toTopOf,layout_constraintTop_toBottomOf,layout_constraintBottom_toTopOf and layout_constraintBottom_toBottomOf property to arrange views vertically.
You can also use LinearLayout if UI is quite simple and If you use ConstraintLayout you have to give proper constraints so that ui will not look different in device as well as in preview
I have modified your code so please check below code for now so replace below code in your xml file.
<?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:background="#451C80">
<TextView
android:id="#+id/getStarted"
style="#style/password"
android:layout_width="178dp"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginEnd="148dp"
android:gravity="center"
android:text="#string/password"
android:textAppearance="#style/password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="34dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="11dp"
android:src="#drawable/ic_back"
app:layout_constraintEnd_toStartOf="#+id/getStarted"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView"
style="#style/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="138dp"
android:layout_marginEnd="220dp"
android:layout_marginBottom="32dp"
android:text="#string/set_password"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="#id/textInputLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView3"
style="#style/password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:text="Confirm Password"
android:textSize="16sp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/textInputLayout"
app:layout_constraintStart_toStartOf="#id/textView" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="318dp"
android:layout_height="44dp"
android:layout_marginTop="20dp"
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/editText3"
android:layout_width="318dp"
android:layout_height="44dp"
android:background="#drawable/username_edittext"
android:inputType="textPassword"
tools:ignore="TouchTargetSizeCheck" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout2"
android:layout_width="318dp"
android:layout_height="44dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="506dp"
app:endIconMode="password_toggle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/textView3"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="316dp"
android:layout_height="47dp"
android:layout_marginStart="1dp"
android:background="#drawable/username_edittext"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Related

Center the ConstraintLayout in the screen

I'm trying to vertically center a ConstraintLayout in the screen. The ConstraintLayout is the root element of the entire layout of the LoginActivity.
I set the android:layout_gravity to center (as in the code below). It does the job in the Android Studio Design Editor, but when I run the app on the phone the ConstraintLayout is aligned to the top of the screen.
How can I effectively center the ConstraintLayout in the screen? Thanks.
<?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="wrap_content"
android:layout_gravity="center"
tools:context=".activities.LoginActivity">
<ImageView
android:id="#+id/ivLogo"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:contentDescription="#string/cutitapp_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_cutitapp_logo"
tools:srcCompat="#drawable/ic_cutitapp_logo" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilEmail"
style="#style/CutitApp.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="24dp"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/ivLogo">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:hint="#string/email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilPassword"
style="#style/CutitApp.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tilEmail"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:hint="#string/password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/etEmail"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/tvError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="16dp"
android:textColor="?attr/colorError"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tilPassword" />
<Button
android:id="#+id/btnLogin"
style="#style/CutitApp.Button"
android:layout_width="0dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:text="#string/login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvError" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btnLogin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/not_a_member" />
<Button
android:id="#+id/btnRegister"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register"
android:textAllCaps="false"
android:textColor="#color/design_default_color_primary"
android:textSize="14sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Here you go.
I just added an extra ConstraintLayout
<?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="wrap_content"
android:layout_gravity="center">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id="#+id/ivLogo"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:contentDescription="#string/cutitapp_logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_cutitapp_logo"
tools:srcCompat="#drawable/ic_cutitapp_logo" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilEmail"
style="#style/CutitApp.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="24dp"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/ivLogo">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:hint="#string/email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilPassword"
style="#style/CutitApp.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tilEmail"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints=""
android:hint="#string/password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/etEmail"
tools:ignore="TextContrastCheck" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/tvError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="16dp"
android:textColor="?attr/colorError"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tilPassword" />
<Button
android:id="#+id/btnLogin"
style="#style/CutitApp.Button"
android:layout_width="0dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:text="#string/login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvError" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:gravity="center"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btnLogin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/not_a_member" />
<Button
android:id="#+id/btnRegister"
style="#style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register"
android:textAllCaps="false"
android:textColor="#color/design_default_color_primary"
android:textSize="14sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Why does the height of my Constraintlayout increase when I place it in a Scrollview?

I have a ConstraintLayout which shows all items on my smartphone without the need to scroll. Nevertheless I want to surround the ConstraintLayout with a ScrollView that a user with smaller phones can scroll.
When adding the ScrollView, even on my smartphone I need to scroll to reach the last to buttons. The height of the ConstraintLayout increases and the two buttons with id="#+id/button3" and id="#+id/button4" appear after a big empty area.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<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:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="#+id/button3"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="16dp"
android:drawableLeft="#drawable/ic_chevron_left_black_24dp"
android:onClick="zurueckZuMainActivity"
android:text="Zurück"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="#+id/button4"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="16dp"
android:drawableRight="#drawable/ic_chevron_right_black_24dp"
android:onClick="weiter"
android:text="Weiter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Bestellformular"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:text="Schritt 1/4: Lieferadresse"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6" />
<ImageView
android:id="#+id/imageView9"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="#+id/textInputLayout_vorname"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_vorname"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/textInputLayout_vorname"
app:layout_constraintVertical_bias="0.523"
app:srcCompat="#drawable/ic_person_black_24dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_vorname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView9"
app:layout_constraintTop_toBottomOf="#+id/textView7"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/vorname_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Vorname"
android:inputType="textCapWords"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_nachname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/textInputLayout_vorname"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_vorname">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nachname"
android:inputType="textCapWords"
android:id="#+id/nachname_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView11"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_strasse"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_telefonnummer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView9"
app:layout_constraintVertical_bias="0.587"
app:srcCompat="#drawable/ic_phone_black_24dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_telefonnummer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView11"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_nachname">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Telefonnummer"
android:id="#+id/telefonnummer_edit"
android:inputType="number"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView12"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="#+id/textInputLayout_email"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_email"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_telefonnummer"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="#drawable/ic_email_black_24dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView12"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_telefonnummer">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="E-Mail-Adresse"
android:id="#+id/email_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView13"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="300dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="248dp"
app:layout_constraintBottom_toTopOf="#+id/button3"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_strasse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_vorname"
app:layout_constraintVertical_bias="0.361"
app:srcCompat="#drawable/ic_location_on_black_24dp" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_strasse"
android:layout_width="0dp"
android:layout_height="53dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="7dp"
android:layout_marginBottom="23dp"
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_stadt"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_nummer"
app:layout_constraintStart_toEndOf="#+id/imageView13"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_email"
app:layout_constraintVertical_bias="0.13">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Straße"
android:inputType="textCapWords"
android:id="#+id/strasse_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_nummer"
android:layout_width="152dp"
android:layout_height="53dp"
android:layout_marginTop="34dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textInputLayout_strasse"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_email">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/nummer_edit"
android:layout_width="163dp"
android:layout_height="wrap_content"
android:hint="Nummer"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_plz"
android:layout_width="108dp"
android:layout_height="56dp"
android:layout_marginStart="55dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="12dp"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_stadt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_strasse">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="106dp"
android:layout_height="44dp"
android:hint="PLZ"
android:id="#+id/plz_edit"
android:inputType="number"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_stadt"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textInputLayout_plz"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_nummer"
app:layout_constraintVertical_bias="0.0">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Stadt"
android:id="#+id/stadt_edit"
android:inputType="textCapWords"
/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="1dp"
android:text="Füllen Sie bitte alle nachfolgenden Felder aus! "
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_vorname"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
</androidx.constraintlayout.widget.ConstraintLayout>
How can I solve this?
yu have used fillviewport="true" which basically increases the height of your scroll view to use remaining space if there is extra space available in viewport. If you will make it false, the height of the viewport will be as you expected.
Try wrapping your Buttons in their own ConstraintLayout, inside linearLayout3
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="match_parent"
android:layout_height="0dp">
<Button
android:id="#+id/button4"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="16dp"
android:onClick="weiter"
android:text="Weiter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="#+id/button3"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="16dp"
android:onClick="zurueckZuMainActivity"
android:text="Zurück"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
You could try to add a RelativeLayout:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="Bestellformular"
android:textAppearance="#style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:text="Schritt 1/4: Lieferadresse"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView6" />
<ImageView
android:id="#+id/imageView9"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="#+id/textInputLayout_vorname"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_vorname"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/textInputLayout_vorname"
app:layout_constraintVertical_bias="0.523"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_vorname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView9"
app:layout_constraintTop_toBottomOf="#+id/textView7"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/vorname_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Vorname"
android:inputType="textCapWords"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_nachname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#+id/textInputLayout_vorname"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_vorname">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nachname"
android:inputType="textCapWords"
android:id="#+id/nachname_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView11"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="20dp"
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_strasse"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_telefonnummer"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView9"
app:layout_constraintVertical_bias="0.587"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_telefonnummer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView11"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_nachname">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Telefonnummer"
android:id="#+id/telefonnummer_edit"
android:inputType="number"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView12"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="#+id/textInputLayout_email"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_email"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_telefonnummer"
app:layout_constraintVertical_bias="1.0"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView12"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_telefonnummer">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="E-Mail-Adresse"
android:id="#+id/email_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/imageView13"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="300dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="248dp"
app:layout_constraintBottom_toTopOf="#+id/button3"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_strasse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_vorname"
app:layout_constraintVertical_bias="0.361"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_strasse"
android:layout_width="0dp"
android:layout_height="53dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="7dp"
android:layout_marginBottom="23dp"
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_stadt"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_nummer"
app:layout_constraintStart_toEndOf="#+id/imageView13"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_email"
app:layout_constraintVertical_bias="0.13">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Straße"
android:inputType="textCapWords"
android:id="#+id/strasse_edit"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_nummer"
android:layout_width="152dp"
android:layout_height="53dp"
android:layout_marginTop="34dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textInputLayout_strasse"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_email">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/nummer_edit"
android:layout_width="163dp"
android:layout_height="wrap_content"
android:hint="Nummer"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_plz"
android:layout_width="108dp"
android:layout_height="56dp"
android:layout_marginStart="55dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="12dp"
app:layout_constraintEnd_toStartOf="#+id/textInputLayout_stadt"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_strasse">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="106dp"
android:layout_height="44dp"
android:hint="PLZ"
android:id="#+id/plz_edit"
android:inputType="number"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout_stadt"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginTop="7dp"
android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textInputLayout_plz"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout_nummer"
app:layout_constraintVertical_bias="0.0">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Stadt"
android:id="#+id/stadt_edit"
android:inputType="textCapWords"
/>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="1dp"
android:text="Füllen Sie bitte alle nachfolgenden Felder aus! "
app:layout_constraintBottom_toTopOf="#+id/textInputLayout_vorname"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="#+id/button3"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:layout_marginBottom="16dp"
android:onClick="zurueckZuMainActivity"
android:text="Zurück"
android:layout_alignParentBottom="true"/>
<Button
android:id="#+id/button4"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="16dp"
android:onClick="weiter"
android:text="Weiter"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
You have used fillviewport="true" which basically increases the height of your scroll view to use remaining space if there is extra space available in viewport. If you will make it false, or just remove that attribute, the height of the constraint layout will be as you expected. By default, the value of fillviewport is false.

Constrain View Issue

I'm trying to make OTP login screen and ran into some issue
following is my XML code. I've used ConstraintLayout and RelativeLayout in this single activity. I did not write any java code yet but setContentView() is also defined
if you look closely to my output you can see the white rectangle on top-left
I think the issue is with XML I might have done something wrong please help
<?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"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="97.71dp"
android:layout_height="0dp"
android:layout_marginTop="135dp"
android:layout_marginBottom="29dp"
android:contentDescription="#string/todo"
android:src="#drawable/verification"
app:layout_constraintBottom_toTopOf="#+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView"
android:layout_width="211dp"
android:layout_height="34dp"
android:layout_marginBottom="27dp"
android:text="#string/content"
android:textAlignment="center"
android:textColor="#898A8F"
android:textSize="11sp"
app:layout_constraintBottom_toTopOf="#+id/relativeLayout3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView"
tools:ignore="SmallSp" />
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="322dp"
android:layout_height="154dp"
android:layout_marginStart="48dp"
android:layout_marginLeft="48dp"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:layout_marginBottom="275dp"
android:background="#drawable/background"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.571"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView"
tools:targetApi="lollipop">
<TextView
android:layout_width="60dp"
android:layout_height="44dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="21dp"
android:background="#drawable/ed_txt_bg"
android:drawableLeft="#drawable/flag"
android:gravity="center"
android:text="#string/num"
android:textAlignment="center"
android:textColor="#313450"
android:textSize="19sp"
android:textStyle="bold"
tools:ignore="RtlHardcoded" />
<EditText
android:layout_width="216dp"
android:layout_height="44dp"
android:layout_marginStart="83dp"
android:layout_marginLeft="83dp"
android:layout_marginTop="21dp"
android:background="#drawable/ed_txt_bg"
android:importantForAutofill="no"
android:inputType="text"
tools:ignore="LabelFor" />
<Button
android:layout_width="280.9dp"
android:layout_height="44dp"
android:layout_marginStart="17dp"
android:layout_marginLeft="17dp"
android:layout_marginTop="95.56dp"
android:background="#drawable/button_bg"
android:text="#string/submit"
android:textColor="#fff" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
This is suppose to be Output
But this happens when I run it
can you tell me how to fix?
you can try following code
<?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">
<androidx.cardview.widget.CardView
android:id="#+id/cardView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:cardCornerRadius="4dp"
app:cardElevation="6dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/editText"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:ems="3"
android:hint="+91"
android:inputType="number"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:ems="10"
android:inputType="phone"
android:text="1234567890"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/editText"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
style="#style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:background="#android:color/holo_blue_light"
android:text="#string/submit"
android:textColor="#3C3F41"
app:backgroundTint="#03A9F4"
app:cornerRadius="24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Enter your mobile number, we will send you otp"
app:layout_constraintBottom_toTopOf="#+id/cardView2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="85dp"
android:layout_height="85dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toTopOf="#+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="#android:drawable/sym_def_app_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>
Add material dependency to your project and replace your images and ids for views.

Android layout doesn´t resize when keyboard shows

as title says, i have a problem resizing my layout when keyboard appears, I did the same in new project and it works, nope in this project:
I have added "android:windowSoftInputMode="adjustResize" in my activity manifest file
This is my .xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/contentRegister1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true">
<include
android:id="#+id/customActionBar"
layout="#layout/action_bar_text"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/customActionBar">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvInfoRegister"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="30dp"
android:text="#string/register_header_text"
android:textAlignment="center"
android:textColor="#ff999999"
android:textSize="13sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/nifRegisterBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="22dp"
android:layout_marginEnd="30dp"
android:textColorHint="#android:color/black"
app:boxStrokeColor="#android:color/black"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextFormStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvInfoRegister">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/nifRegisterValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/nif_nie"
android:inputType="textCapCharacters"
android:maxLength="9"
android:maxLines="1"
android:textColor="#000000"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/ivOkNifRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_tick"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/nifRegisterBox"
app:layout_constraintEnd_toEndOf="#id/nifRegisterBox"
app:layout_constraintTop_toTopOf="#id/nifRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<ImageView
android:id="#+id/ivWrongNifRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_error"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/nifRegisterBox"
app:layout_constraintEnd_toEndOf="#id/nifRegisterBox"
app:layout_constraintTop_toTopOf="#id/nifRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/birthRegisterBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="30dp"
android:textColorHint="#android:color/black"
app:boxStrokeColor="#android:color/black"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextFormStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nifRegisterBox">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/birthRegisterValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="false"
android:hint="#string/register_birthdate_label"
android:inputType="date"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/ivOkBirthRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_tick"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/birthRegisterBox"
app:layout_constraintEnd_toEndOf="#id/birthRegisterBox"
app:layout_constraintTop_toTopOf="#id/birthRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<ImageView
android:id="#+id/ivWrongBirthRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_error"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/birthRegisterBox"
app:layout_constraintEnd_toEndOf="#id/birthRegisterBox"
app:layout_constraintTop_toTopOf="#id/birthRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/mailRegisterBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="30dp"
android:textColorHint="#android:color/black"
app:boxStrokeColor="#android:color/black"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextFormStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/birthRegisterBox">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/mailRegisterValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/register_email_label"
android:inputType="textEmailAddress"
android:maxLines="1"
android:textColor="#000000"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/ivOkMailRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_tick"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/mailRegisterBox"
app:layout_constraintEnd_toEndOf="#id/mailRegisterBox"
app:layout_constraintTop_toTopOf="#id/mailRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<ImageView
android:id="#+id/ivWrongMailRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_error"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/mailRegisterBox"
app:layout_constraintEnd_toEndOf="#id/mailRegisterBox"
app:layout_constraintTop_toTopOf="#id/mailRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/remailRegisterBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="30dp"
android:textColorHint="#android:color/black"
app:boxStrokeColor="#android:color/black"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextFormStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mailRegisterBox">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/remailRegisterValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/register_email_confirm_label"
android:inputType="textEmailAddress"
android:maxLines="1"
android:textColor="#000000"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/ivOkReMailRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_tick"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/remailRegisterBox"
app:layout_constraintEnd_toEndOf="#id/remailRegisterBox"
app:layout_constraintTop_toTopOf="#id/remailRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<ImageView
android:id="#+id/ivWrongReMailRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_error"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/remailRegisterBox"
app:layout_constraintEnd_toEndOf="#id/remailRegisterBox"
app:layout_constraintTop_toTopOf="#id/remailRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/mobileRegisterBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="30dp"
android:textColorHint="#android:color/black"
app:boxStrokeColor="#android:color/black"
app:errorEnabled="true"
app:hintTextAppearance="#style/TextFormStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/remailRegisterBox">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/mobileRegisterValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/register_mobile_phone_label"
android:inputType="number"
android:maxLength="9"
android:maxLines="1"
android:textColor="#000000"
android:textSize="15sp" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="#+id/ivOkMobileRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_tick"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/mobileRegisterBox"
app:layout_constraintEnd_toEndOf="#id/mobileRegisterBox"
app:layout_constraintTop_toTopOf="#id/mobileRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<ImageView
android:id="#+id/ivWrongMobileRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="#drawable/ic_error"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="#id/mobileRegisterBox"
app:layout_constraintEnd_toEndOf="#id/mobileRegisterBox"
app:layout_constraintTop_toTopOf="#id/mobileRegisterBox"
app:layout_constraintVertical_bias="0.39" />
<LinearLayout
android:id="#+id/check_box_and_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="30dp"
android:clickable="true"
android:focusable="true"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mobileRegisterBox">
<CheckBox
android:id="#+id/legales"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="9dp"
android:button="#drawable/checkbox_selector" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:text="#string/register_legales_label"
android:textSize="13sp" />
<TextView
android:id="#+id/termsOfAgreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register_legales_label_hiperlink"
android:textColor="#ffd87920"
android:textSize="13sp" />
</LinearLayout>
<TextView
android:id="#+id/tvErrorLegal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:text="#string/condiciones_legales_error"
android:textColor="#ff0000"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/check_box_and_text" />
<Button
android:id="#+id/btNextRegister1"
style="#style/LoginButtonEntrarStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:layout_marginTop="27dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="32dp"
android:background="#drawable/button_main_card_dashboard"
android:text="#string/request_reset_password_init_button_next"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvErrorLegal" />
</androidx.constraintlayout.widget.ConstraintLayout>
And this is the include file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/dashboard_title_bg">
<TextView
android:id="#+id/actionBarCentralTextView"
style="#style/MainTitleActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6" />
<ImageButton
android:id="#+id/btActionBarMenuText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="?android:selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/back_container_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.6">
<ImageButton
android:id="#+id/btActionBarNotificationsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:background="?android:selectableItemBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvSecondTitleText"
style="#style/SecondaryTitleActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Anyone knows why it is not resizing?
Thanks,
By it's standard documentation:
Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows.
I think your problem would be solved by adding android:fitsSystemWindows=true to your root view.

How to have same vertical weight between group of components in Constraint Layout Android?

I am usin Constraint layout . What i want is to have same vetical weight(width) between group1 and group2, and group2 and end of screen.In linear layout i would put one group to vertical linear layout and group2 same to vertical linear layout and put that two layouts in parrent vertical layout and set weight to 1. But how to do that in constraint layout?
Here is sample picture:
So what i want is to have same width space between group1 and group2 and group2 and end of screen.
Like this:
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:id="#+id/constrait"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="47dp"
app:layout_constraintVertical_chainStyle="spread"
app:layout_constraintVertical_weight="4"
tools:context="example.com.constrait.MainActivity">
<TextView
android:id="#+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="24dp" />
<EditText
android:id="#+id/editText6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:background="#drawable/rounded_border_edittext"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="#+id/textView7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView7" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText6" />
<EditText
android:id="#+id/editText8"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:background="#drawable/rounded_border_edittext"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="#+id/textView8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView8" />
You are probably looking for Chains.
You can look at this blogpost where I took the following snippets from.
Basically you want to chain together your widgets like this
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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">
<Button
android:id="#+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View 1"
app:layout_constraintRight_toLeftOf="#+id/view2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View 2"
app:layout_constraintRight_toLeftOf="#+id/view3"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintLeft_toRightOf="#+id/view1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View 3"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintLeft_toRightOf="#+id/view2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
And for your specific use case, you might want to use
app:layout_constraintHorizontal_chainStyle=”spread”
I have modified your code as per the need test this code and see if it works for you:-
<android.support.constraint.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.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="#+id/constraintLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<TextView
android:id="#+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView15"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView15"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView16"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView11"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView16"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView17"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView15"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView17"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView16"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText13"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText10"
app:layout_constraintTop_toTopOf="#+id/editText10" />
<EditText
android:id="#+id/editText10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText12"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView11" />
<EditText
android:id="#+id/editText13"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText14"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText12"
app:layout_constraintTop_toTopOf="#+id/editText12" />
<EditText
android:id="#+id/editText14"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText13"
app:layout_constraintTop_toTopOf="#+id/editText13" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="#+id/constraintLayout2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/constraintLayout">
<TextView
android:id="#+id/textView21"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView22"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView22"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView23"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView21"
app:layout_constraintTop_toTopOf="#+id/textView21" />
<TextView
android:id="#+id/textView23"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toStartOf="#+id/textView25"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView22"
app:layout_constraintTop_toTopOf="#+id/textView22" />
<TextView
android:id="#+id/textView25"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/textView23"
app:layout_constraintTop_toTopOf="#+id/textView23" />
<EditText
android:id="#+id/editText15"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText16"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView21" />
<EditText
android:id="#+id/editText16"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText17"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText15"
app:layout_constraintTop_toTopOf="#+id/editText15" />
<EditText
android:id="#+id/editText17"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toStartOf="#+id/editText18"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText16"
app:layout_constraintTop_toTopOf="#+id/editText15" />
<EditText
android:id="#+id/editText18"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toEndOf="#+id/editText17"
app:layout_constraintTop_toTopOf="#+id/editText15" />
</android.support.constraint.ConstraintLayout>
I have edited layout as per the need. Take a look now. Add edit text background as per your need.

Categories

Resources