I am using InputEditTextLayout Outline Dense.
The stroke is cut out like this when hint enabled= off but shown correctly when hint is enabled.
https://ibb.co/yPrjHJ2
https://ibb.co/WD8Lktc
I tried putting padding and margins but nothing works. I couldn't find how to set padding for background in InputEditTextLayout.
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_marginTop="124dp"
android:minHeight="10dp"
android:paddingBottom="16dp"
android:src="#drawable/signin_header"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout2"
style="#style/LoginTextInputLayoutStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:hintEnabled="false"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toStartOf="#+id/guideline2"
app:layout_constraintHorizontal_bias="0.0"
android:paddingBottom="4dp"
android:paddingTop="2dp"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/imageView2">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:paddingStart="16dp"
android:layout_gravity="center"
android:inputType="textEmailAddress"
android:textColor="#color/LightBlack"
android:textColorHint="#color/LightBlack"
android:textSize="16dp" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
style="#style/LoginTextInputLayoutStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginVertical="#dimen/tex_size_default"
android:layout_marginTop="32dp"
app:hintEnabled="false"
android:paddingBottom="2dp"
android:paddingTop="2dp"
app:layout_constraintEnd_toStartOf="#+id/guideline2"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout2"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password"
android:inputType="textPassword"
android:paddingStart="16dp"
android:textColorHint="#color/LightBlack"
android:textColor="#color/LightBlack"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/not_regis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:paddingEnd="5dp"
android:text="Not registered?"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="#dimen/tex_size_default"
app:layout_constraintStart_toStartOf="#+id/textView13"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
<TextView
android:id="#+id/login_signup"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="wrap_content"
android:layout_height="26dp"
android:layout_toEndOf="#+id/not_regis"
android:onClick="signup_screen"
android:text="Sign Up"
android:textAlignment="center"
android:textColor="#F57C00"
android:textSize="#dimen/tex_size_default"
android:textStyle="bold"
app:layout_constraintBaseline_toBaselineOf="#+id/not_regis"
app:layout_constraintStart_toEndOf="#+id/not_regis" />
<com.google.android.material.button.MaterialButton
android:id="#+id/login_login"
style="#style/RoundButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="92dp"
android:layout_marginTop="32dp"
android:onClick="login"
android:padding="10dp"
android:text="LOGIN"
android:textColor="#android:color/black"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout" />
<TextView
android:id="#+id/textView13"
android:layout_width="137dp"
android:layout_height="23dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="8dp"
android:layout_marginTop="40dp"
android:onClick="forgetpassword"
android:text="Forgot password"
android:textColor="#F57C00"
android:textSize="#dimen/tex_size_default"
app:layout_constraintStart_toStartOf="#+id/guideline3"
app:layout_constraintTop_toBottomOf="#+id/login_login" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.84" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.16" />
</androidx.constraintlayout.widget.ConstraintLayout>
You can try below sample one to showing correctly TextInpuLayout Stroke. You can also refer them for a more complete solution.
<TextView
android:id="#+id/not_regis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:paddingEnd="5dp"
android:text="Not registered?"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="#dimen/tex_size_default"
app:layout_constraintStart_toStartOf="#+id/textView13"
app:layout_constraintTop_toBottomOf="#+id/textView13" />
Try this one example which I have used.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/user_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="42dp"
android:layout_marginTop="87dp"
android:layout_marginEnd="42dp"
android:theme="#style/TextLabel"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/tv_bold_line">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="#+id/ed_user_name"
style="#style/TextViewSingleLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:drawableEndCompat="#drawable/ic_user"
android:hint="#string/user_name"
android:imeOptions="actionNext"
android:paddingBottom="16dp"
android:textSize="#dimen/login_text" />
</com.google.android.material.textfield.TextInputLayout>
Related
I am making signup page using this image background.
Background image
It Look like: Signup page
But when I focus on EditText and when keyboard is opened, the background image is compressed. How can I resolve this.
After Compressed :
Here XML code:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/log_sign_bg">
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="260dp">
<EditText
android:id="#+id/editText"
style="#android:style/TextAppearance.Material.Medium"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="#drawable/edittext_background"
android:hint="Username"
android:inputType="textPersonName"
android:paddingLeft="8dp"
android:textAppearance="#android:style/TextAppearance.Material.Medium"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText3"
style="#android:style/TextAppearance.Material.Medium"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:background="#drawable/edittext_background"
android:hint="Email"
android:inputType="textEmailAddress"
android:paddingLeft="8dp"
android:textAppearance="#android:style/TextAppearance.Material.Medium"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText"
app:layout_constraintStart_toStartOf="#+id/editText"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<EditText
android:id="#+id/editText2"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:background="#drawable/edittext_background"
android:hint="Password"
android:inputType="textPassword"
android:paddingLeft="8dp"
android:textAppearance="#android:style/TextAppearance.Material.Medium"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText3"
app:layout_constraintStart_toStartOf="#+id/editText3"
app:layout_constraintTop_toBottomOf="#+id/editText3" />
<EditText
android:id="#+id/editText4"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:background="#drawable/edittext_background"
android:hint="Re-enter Password"
android:inputType="textPassword"
android:paddingLeft="8dp"
android:textAppearance="#android:style/TextAppearance.Material.Medium"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText2"
app:layout_constraintStart_toStartOf="#+id/editText2"
app:layout_constraintTop_toBottomOf="#+id/editText2" />
<Button
android:id="#+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="64dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="64dp"
android:background="#drawable/button_background"
android:text="Register"
android:textAppearance="#android:style/TextAppearance.Material.Large"
android:textColor="#FFF"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/editText4"
app:layout_constraintStart_toStartOf="#+id/editText4"
app:layout_constraintTop_toBottomOf="#+id/editText4" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="24dp"
android:text="Already a member?"
android:textColor="#A6A6A6"
android:textSize="22dp"
app:layout_constraintEnd_toStartOf="#+id/textView2"
app:layout_constraintStart_toStartOf="#+id/button"
app:layout_constraintTop_toBottomOf="#+id/button" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="24dp"
android:text="Login"
android:textColor="#EF3646"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/button"
app:layout_constraintStart_toEndOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/button" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I tried to many ways but i think i have to separate the bakgrounf image and the logo one may be fix it.
Into your AndroidManifest.xml file add below line to your activity
android:windowSoftInputMode="stateVisible|adjustPan"
Like below snippet register in
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="stateVisible|adjustPan|adjustResize" />
You mentioned issue in comment section so solution is here,
Run time Set Edittext Hint:
EditText etName;
etName= (EditText) findViewById(R.id.etName);
etName.setHint("Your Hint");
Your xml file is not correct ScrollView can not contain multiple child, i have resolved your problem.So Please follow my answer.
if you want to scroll only view not top image then use this one
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/signup_bg"
>
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:layout_marginTop="260dp"
android:layout_marginEnd="16dp"
android:hint="Username"
android:inputType="textPersonName"
android:paddingLeft="8dp"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/editText3"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:hint="Email"
android:inputType="textEmailAddress"
android:paddingLeft="8dp"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText"
app:layout_constraintStart_toStartOf="#+id/editText"
app:layout_constraintTop_toBottomOf="#+id/editText" />
<EditText
android:id="#+id/editText2"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:hint="Password"
android:inputType="textPassword"
android:paddingLeft="8dp"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText3"
app:layout_constraintStart_toStartOf="#+id/editText3"
app:layout_constraintTop_toBottomOf="#+id/editText3" />
<EditText
android:id="#+id/editText4"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="16dp"
android:hint="Re-enter Password"
android:inputType="textPassword"
android:paddingLeft="8dp"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/editText2"
app:layout_constraintStart_toStartOf="#+id/editText2"
app:layout_constraintTop_toBottomOf="#+id/editText2" />
<Button
android:id="#+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginStart="64dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="64dp"
android:background="#EF3646"
android:text="Register"
android:textColor="#FFF"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="#+id/editText4"
app:layout_constraintStart_toStartOf="#+id/editText4"
app:layout_constraintTop_toBottomOf="#+id/editText4" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="24dp"
android:text="Already a member?"
android:textColor="#A6A6A6"
android:textSize="22dp"
app:layout_constraintEnd_toStartOf="#+id/textView2"
app:layout_constraintStart_toStartOf="#+id/button"
app:layout_constraintTop_toBottomOf="#+id/button" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="24dp"
android:text="Login"
android:textColor="#EF3646"
android:textSize="22dp"
app:layout_constraintEnd_toEndOf="#+id/button"
app:layout_constraintStart_toEndOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/button" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Hi I am new to using android studio and I do not get why the layout that I am seeing in the preview of the IDE does not match with the ones that I am seeing on my screen. I am using Samsung J7 Prime.
This is what I see in the preview
however, this is what I see on my device.
Please help, thank you in advance.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:layout_marginEnd="32dp"
android:text="#string/original_price"
app:layout_constraintBaseline_toBaselineOf="#+id/etNum1"
app:layout_constraintEnd_toStartOf="#+id/etNum1"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="72dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="60dp"
android:text="#string/rate"
app:layout_constraintEnd_toStartOf="#+id/etNum2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/etNum2" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:layout_marginEnd="61dp"
android:text="#string/discount"
app:layout_constraintEnd_toStartOf="#+id/etNum3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/etNum3" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="65dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="46dp"
android:text="#string/sales_price"
app:layout_constraintEnd_toStartOf="#+id/etNum4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/etNum4" />
<EditText
android:id="#+id/etNum1"
android:layout_width="0dp"
android:layout_height="39dp"
android:layout_marginTop="101dp"
android:layout_marginEnd="75dp"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/etNum2"
android:layout_width="0dp"
android:layout_height="37dp"
android:layout_marginTop="79dp"
android:layout_marginEnd="72dp"
android:layout_marginBottom="80dp"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum2"
app:layout_constraintBottom_toBottomOf="#+id/etNum3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView2"
app:layout_constraintTop_toTopOf="#+id/textView" />
<EditText
android:id="#+id/etNum3"
android:layout_width="0dp"
android:layout_height="34dp"
android:layout_marginTop="143dp"
android:layout_marginEnd="76dp"
android:layout_marginBottom="143dp"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum3"
app:layout_constraintBottom_toTopOf="#+id/calculate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView3"
app:layout_constraintTop_toBottomOf="#+id/textView"
android:editable="false"/>
<EditText
android:id="#+id/etNum4"
android:layout_width="0dp"
android:layout_height="39dp"
android:layout_marginTop="47dp"
android:layout_marginEnd="72dp"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView4"
app:layout_constraintTop_toBottomOf="#+id/etNum3"
android:editable="false"/>
<Button
android:id="#+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginBottom="229dp"
android:text="#string/compute"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/textView4" />
<Button
android:id="#+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="29dp"
android:text="#string/erase"
app:layout_constraintStart_toStartOf="#+id/calculate"
app:layout_constraintTop_toBottomOf="#+id/calculate" />
</android.support.constraint.ConstraintLayout>
You are using a fixed size in a lot of places for your views(for example android:layout_marginTop="79dp" and android:layout_height="37dp").
Because different phones got different screen size, when you are using a fixed size on your view you are making your layout less responsive.
If you want to place some view anywhere at your screen I would recommend using guielines and constraint your views into the guideline rather then give your view a fixed size value to fit the preview(don't forget that with fixed sizes what may fit one screen may not fit another screen).
For your desired layout you can simply use chains.
Here is an example of the layout that you want to achieve using cnostraintLayout and chains:
<?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">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/original_price"
app:layout_constraintBottom_toTopOf="#+id/textView2"
app:layout_constraintEnd_toStartOf="#+id/etNum1"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/rate"
app:layout_constraintBottom_toTopOf="#+id/textView3"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/textView" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/discount"
app:layout_constraintBottom_toTopOf="#+id/textView4"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<TextView
android:id="#+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/sales_price"
app:layout_constraintBottom_toTopOf="#+id/calculate"
app:layout_constraintEnd_toEndOf="#+id/textView"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/textView"
app:layout_constraintTop_toBottomOf="#+id/textView3" />
<EditText
android:id="#+id/etNum1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum1"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/textView"
app:layout_constraintTop_toTopOf="#+id/textView" />
<EditText
android:id="#+id/etNum2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:autofillHints=""
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum2"
app:layout_constraintBottom_toBottomOf="#+id/textView2"
app:layout_constraintEnd_toEndOf="#+id/etNum1"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/etNum1"
app:layout_constraintTop_toTopOf="#+id/textView2" />
<EditText
android:id="#+id/etNum3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:autofillHints=""
android:editable="false"
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum3"
app:layout_constraintBottom_toBottomOf="#+id/textView3"
app:layout_constraintEnd_toEndOf="#+id/etNum1"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/etNum1"
app:layout_constraintTop_toTopOf="#+id/textView3" />
<EditText
android:id="#+id/etNum4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:autofillHints=""
android:editable="false"
android:ems="10"
android:inputType="number"
android:labelFor="#id/etNum4"
app:layout_constraintBottom_toBottomOf="#+id/textView4"
app:layout_constraintEnd_toEndOf="#+id/etNum1"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/etNum1"
app:layout_constraintTop_toTopOf="#+id/textView4" />
<Button
android:id="#+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="compute"
app:layout_constraintBottom_toTopOf="#+id/clear"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView4" />
<Button
android:id="#+id/clear"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="erase"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/calculate"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="#+id/calculate"
app:layout_constraintTop_toBottomOf="#+id/calculate" />
</android.support.constraint.ConstraintLayout>
And it will look like this:
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title 1" />
<EditText
android:id="#+id/etNum1"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Title 1"
android:inputType="number"
android:labelFor="#id/etNum1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title 2" />
<EditText
android:id="#+id/etNum2"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Title 2"
android:inputType="number"
android:labelFor="#id/etNum1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title 3" />
<EditText
android:id="#+id/etNum3"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Title 3"
android:inputType="number"
android:labelFor="#id/etNum1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title 4" />
<EditText
android:id="#+id/etNum4"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_marginStart="20dp"
android:ems="10"
android:hint="Title 4"
android:inputType="number"
android:labelFor="#id/etNum1" />
</LinearLayout>
<Button
android:id="#+id/calculate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:text="Button 1" />
<Button
android:id="#+id/clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="Button 2" />
</LinearLayout>
Remove all constraints top of and remap them according to what should be on top of for example textView should be on top of textView1 Goodluck
I have added xml for my layout edit text is not getting focus, only selects first one then cannot selects another edittext
I am afraid that somehow focus is not getting or is messed up but could not resolve it anyway.
maybe constraintlayout is culprit but no idea.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_layout" />
<ScrollView
android:id="#+id/svScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintBottom_toTopOf="#+id/btUpdate"
>
<android.support.constraint.ConstraintLayout
android:id="#+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
>
<EditText
android:id="#+id/etEmailid"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/profile_background"
android:hint="#string/email_txt"
android:padding="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:inputType="text" />
<EditText
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/First_name"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etEmailid"
/>
<EditText
android:id="#+id/etLastName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/last_name"
android:inputType="textCapWords"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etFirstName" />
<TextView
android:id="#+id/dob"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:drawablePadding="10dp"
android:drawableEnd="#mipmap/mdate"
android:gravity="center_vertical"
android:padding="10dp"
android:hint="#string/dob"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toStartOf="#+id/genderSpinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etLastName" />
<Spinner
android:id="#+id/genderSpinner"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:background="#drawable/profile_background"
android:entries="#array/gender"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/dob"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/dob"
app:layout_constraintTop_toTopOf="#+id/dob"/>
<EditText
android:id="#+id/etMobileno"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/mobile_txt"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/genderSpinner" />
<EditText
android:id="#+id/etAddress"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/address"
android:inputType="textCapWords"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etMobileno" />
<EditText
android:id="#+id/etCity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/S_city"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etAddress" />
<EditText
android:id="#+id/etPincode"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/pincode"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etCity" />
<TextView
android:id="#+id/tvMandatory"
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_marginTop="10dp"
android:text="#string/mandatory"
android:textColor="#color/white"
android:textSize="10sp"
android:gravity="right"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etPincode" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/ivProfile"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="10dp"
android:src="#drawable/prof_img"
app:civ_border_color="#000"
app:civ_border_width="0.5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvMandatory" />
<TextView
android:id="#+id/tvChoosePhoto"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:background="#drawable/prof_cam"
android:gravity="center|left"
android:paddingLeft="#dimen/plus_15dp"
android:text="CHOOSE YOUR PHOTO"
android:textColor="#color/black"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="#+id/ivProfile"
app:layout_constraintLeft_toRightOf="#+id/ivProfile"
app:layout_constraintTop_toTopOf="#+id/ivProfile" />
<TextView
android:id="#+id/tvClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:gravity="center|left"
android:text="#string/clear"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/tvChoosePhoto"
app:layout_constraintLeft_toRightOf="#+id/tvChoosePhoto"
app:layout_constraintTop_toTopOf="#+id/tvChoosePhoto"
tools:ignore="MissingConstraints" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
<Button
android:id="#+id/btUpdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_update"
android:text="UPDATE"
android:layout_marginBottom="10dp"
android:textColor="#color/white"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
This shows that I am using scrollview inside constraintlayout which has multiple edit texts and cannot focus second or any of other elements
You can use android:imeOptions="actionNext" to get focus on next EditText item in layout. I have used EditText( or AppCompatEditText) within ConstrainLayout in Scrollview, it working fine.
Hello I have an issue with my layout. Its working properly on preview mode and on an emulator with Api level 24 but when I run it on a device with api 19 it just breaks up and gets all messed up. Even my edit text fields end up unresponsive. here I paste my XML code to see if you guys coud help me out.
EDIT: I am very sorry I've pasted the wrong code (it was incomplete). I have edited and now its correct. Also attached a couple of pictures of how looks in the named devices.
Here is the messed layout And here is the correct one
.Another thing is that I am using one nested constraint layout. Do you thing that could be it?
<?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/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
tools:context="com.cuantomefalta.cuantomefalta.MainActivity">
<EditText
android:id="#+id/weighing3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/cero_percent"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weighing2"
tools:text="25%"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginStart="8dp"/>
<EditText
android:id="#+id/grade3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/one"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toRightOf="#+id/weighing3"
app:layout_constraintRight_toLeftOf="#+id/converted3"
app:layout_constraintTop_toTopOf="#+id/weighing3"
tools:text="100" />
<TextView
android:id="#+id/converted3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="#string/one_point_cero"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/weighing3"
tools:text="8.5"
android:layout_marginTop="2dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"/>
<EditText
android:id="#+id/weighing2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/cero_percent"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weighing1"
tools:text="25%"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginStart="8dp"/>
<EditText
android:id="#+id/grade2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/one"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toRightOf="#+id/weighing2"
app:layout_constraintRight_toLeftOf="#+id/converted2"
app:layout_constraintTop_toTopOf="#+id/weighing2"
tools:text="100" />
<TextView
android:id="#+id/converted2"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="#string/one_point_cero"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/weighing2"
tools:text="8.5"
android:layout_marginTop="0dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"/>
<EditText
android:id="#+id/weighing1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/cero_percent"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/weighing"
tools:text="25%"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginStart="8dp"/>
<EditText
android:id="#+id/grade1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/one"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toRightOf="#+id/weighing1"
app:layout_constraintRight_toLeftOf="#+id/converted1"
app:layout_constraintTop_toTopOf="#+id/weighing1"
tools:text="100"
android:layout_marginTop="0dp"
app:layout_constraintHorizontal_bias="0.5" />
<TextView
android:id="#+id/converted1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_square"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="#string/one_point_cero"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/weighing1"
tools:text="8.5"
android:layout_marginTop="0dp"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"/>
<EditText
android:id="#+id/weighing"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/cero_percent"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="25%"
/>
<EditText
android:id="#+id/grade"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="#drawable/little_square"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:hint="#string/one"
android:imeOptions="actionDone"
android:inputType="number"
android:textColor="#android:color/white"
android:textSize="25sp"
app:layout_constraintLeft_toRightOf="#+id/weighing"
app:layout_constraintRight_toLeftOf="#+id/converted"
app:layout_constraintTop_toTopOf="#+id/weighing"
tools:text="100" />
<TextView
android:id="#+id/converted"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#drawable/little_square"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="#string/one_point_cero"
android:textColor="#android:color/white"
android:textSize="25sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/weighing"
tools:text="1.0" />
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-2505831397151341/8310107897"
ads:layout_constraintBottom_toBottomOf="parent"
ads:layout_constraintHorizontal_bias="0.0"
ads:layout_constraintLeft_toLeftOf="parent"
ads:layout_constraintRight_toRightOf="parent" />
<android.support.constraint.ConstraintLayout
android:id="#+id/shareView"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_gravity="center_vertical"
android:background="#drawable/big_circle"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="#+id/adView"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<TextSwitcher
android:id="#+id/final_grade"
android:layout_width="0dp"
android:layout_height="234dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginTop="-12dp"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:textColor="#android:color/white"
android:textSize="125sp"
tools:text="55" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginTop="-12dp"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:textColor="#android:color/white"
android:textSize="125sp"
tools:text="99" />
</TextSwitcher>
<EditText
android:id="#+id/goalGrade"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:background="#drawable/little_circle"
android:cursorVisible="false"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:inputType="number"
android:imeOptions="actionDone"
android:text="#string/five"
android:textColor="#android:color/white"
android:textSize="30sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:text="#string/five"
android:layout_marginBottom="8dp" />
<TextView
android:id="#+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="#string/me_faltan"
android:textColor="#android:color/white"
android:textSize="25sp"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/shareView"
android:layout_marginTop="24dp"
/>
<TextView
android:id="#+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="#string/para_llegar"
android:textColor="#android:color/white"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="#+id/goalGrade"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/floatingActionButton8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
app:fabSize="mini"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/shareView"
app:srcCompat="#drawable/ic_add_white_24dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/floatingActionButton9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
app:fabSize="mini"
app:layout_constraintLeft_toLeftOf="#+id/floatingActionButton8"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/floatingActionButton8"
app:srcCompat="#drawable/ic_clear_white_24dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/floatingActionButton10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
app:fabSize="mini"
app:layout_constraintLeft_toLeftOf="#+id/floatingActionButton9"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/floatingActionButton9"
app:srcCompat="#drawable/ic_delete_sweep_white_24dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/floatingActionButton11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
app:fabSize="mini"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/floatingActionButton10"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/floatingActionButton10"
app:layout_constraintBottom_toBottomOf="#id/shareView"
app:srcCompat="#drawable/ic_play_arrow_white_24dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/floatingActionButton12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="0dp"
android:clickable="true"
app:fabSize="mini"
app:layout_constraintRight_toRightOf="#id/shareView"
app:layout_constraintBottom_toBottomOf="#+id/shareView"
app:srcCompat="#drawable/ic_share_white_24dp"
android:visibility="gone"
android:layout_marginBottom="56dp" />
</android.support.constraint.ConstraintLayout>
Check in the build.gradle(module App) for the minSdkVersion & targetSdkVersion, your device might not be in the range, if so correct that
Your display resolution might be the problem.
I have two XML layout files, each has a ScrollView as parent.
While one is working properly, the other one doesn't (each XML has the same hierarchy).
activity_login.xml
<?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="true">
<android.support.constraint.ConstraintLayout
android:id="#+id/login_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tvLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/logo"
android:textSize="50sp"
app:layout_constraintBottom_toTopOf="#+id/guideline2"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
<TextView
android:id="#+id/tvRegisterLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginStart="3dp"
android:text="#string/btn_login"
android:textSize="20sp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toTopOf="#+id/guideline2" />
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/tvRegisterLabel">
<EditText
android:id="#+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/et_email_hint"
android:inputType="textEmailAddress"
android:maxLength="70"
android:maxLines="1"
android:minLines="1"
android:text="akarki#yahoo.com"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<android.support.constraint.Guideline
android:id="#+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.15" />
<android.support.constraint.Guideline
android:id="#+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.85" />
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout7"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout2">
<EditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/et_password_hint"
android:inputType="textPassword"
android:maxLength="30"
android:maxLines="1"
android:minLines="1"
android:text="1234qwer"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:visibility="invisible"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout7" />
<Button
android:id="#+id/btnLogIn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="#drawable/round_button"
android:text="#string/btn_login"
android:textColor="#color/colorWhite"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/progressBar" />
<com.facebook.login.widget.LoginButton
android:id="#+id/btnFacebook"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:paddingBottom="15dp"
android:paddingLeft="15dp"
android:paddingTop="15dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/btnLogIn" />
<ImageButton
android:id="#+id/btnGoogle"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:background="#drawable/google_round_button"
android:scaleType="centerInside"
android:src="#drawable/google_button_background"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/btnFacebook" />
<TextView
android:id="#+id/tvRegister"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:maxLines="2"
android:text="#string/tv_create_account"
android:textAlignment="center"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/tvForgotPassword" />
<TextView
android:id="#+id/tvForgotPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="#string/tv_forgot_password"
android:textAlignment="center"
android:textColor="#color/colorAccent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline3"
app:layout_constraintRight_toLeftOf="#+id/guideline6"
app:layout_constraintTop_toBottomOf="#+id/btnGoogle" />
</android.support.constraint.ConstraintLayout>
activity_register
<?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="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<android.support.constraint.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
<android.support.constraint.Guideline
android:id="#+id/guideline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.15" />
<android.support.constraint.Guideline
android:id="#+id/guideline5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.85" />
<TextView
android:id="#+id/tvLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/logo"
android:textSize="50sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/guideline"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvRegisterLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginStart="3dp"
android:fontFamily="sans-serif"
android:text="#string/label_register"
android:textAllCaps="true"
android:textSize="20sp"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toTopOf="#+id/guideline" />
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/tvRegisterLabel">
<EditText
android:id="#+id/etEmailReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:hint="#string/et_email_hint"
android:inputType="textEmailAddress"
android:maxLength="70"
android:maxLines="1"
android:minLines="1"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout3"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout">
<EditText
android:id="#+id/etNameReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:hint="#string/et_name_hint"
android:inputType="textCapWords"
android:maxLength="30"
android:maxLines="1"
android:minLines="1"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout4"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout3">
<EditText
android:id="#+id/etPasswordReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:hint="#string/et_password_hint"
android:inputType="textPassword"
android:maxLength="30"
android:maxLines="1"
android:minLines="1"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout5"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout4">
<EditText
android:id="#+id/etPasswordConfirmReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:hint="#string/et_password_confirm_hint"
android:inputType="textPassword"
android:maxLength="30"
android:maxLines="1"
android:minLines="1"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/textInputLayout6"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout5">
<EditText
android:id="#+id/etPhoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:hint="#string/et_phone_hint"
android:inputType="phone"
android:maxLength="13"
android:maxLines="1"
android:minLines="1"
android:textSize="#dimen/et_hint_size" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/tvRequired"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/label_required"
android:textAlignment="textStart"
android:textSize="12sp"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout6" />
<Button
android:id="#+id/btnRegister"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:background="#drawable/round_button"
android:text="#string/label_register"
android:textColor="#android:color/white"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/guideline4"
app:layout_constraintRight_toRightOf="#+id/guideline5"
app:layout_constraintTop_toBottomOf="#+id/tvRequired" />
</android.support.constraint.ConstraintLayout>
So, to clarify my problem: In the activity_login the scrollview works correctly, as expected. While in the activity_register the scrollview doesn't scroll to the bottom, I don't know why, because I've used the same hierarcy as in the activity_login.
I've searched in SO for the same problem, but I haven't found any solution to my problem.
Any help would be appreciated, I'm searching for a solution for days.
I don't know for sure why it's a problem, but the problem seems to be your horizontal Guideline. If I delete the Guideline, delete tvLogo's reference to it, and change tvRegisterLabel's reference to app:layout_constraintTop_toBottomOf="#+id/tvLogo", everything works.
I suspect that it is because you seem to have a circular set of rules in your layout. The ConstraintLayout's height is wrap_content, so it has to lay out all of its views to know how big it is. To lay out its views, it must lay out tvLogo. To lay out tvLogo, it must lay out guideline. To lay out guideline, the ConstraintLayout must know how tall it is. And so on.
By the way, it looks like you could perhaps just replace this ConstraintLayout with a LinearLayout.
Sorry couldn't have much reputations to add comment so giving answer,
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
remove padding from this code in activity_register xml, It will solve your problem