I am trying to use a MapActivity inside a ScrollView page. When I run the app to test it, the map cant be clicked correctly because as the user tries to swipe on the map the scrollview takes over and kinda makes it hard to swipe on it.
Here is how it looks(Map included at the very bottom):
<?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"
tools:context=".CreateAds.FurnitureAd.CreateFunP1Fragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/lll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/ad_title"
android:inputType="textPersonName"
android:textColor="#color/colorPrimary"
tools:layout_editor_absoluteX="182dp"
tools:layout_editor_absoluteY="16dp"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/rrr"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="#+id/lll"
app:layout_constraintStart_toStartOf="#+id/lll"
app:layout_constraintTop_toBottomOf="#+id/lll">
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:hint="#string/offer_price"
android:inputType="number"
android:textColor="#color/colorPrimary"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/currency"
android:textColor="#color/colorPrimary"
app:layout_constraintStart_toStartOf="#+id/spinner2"
app:layout_constraintTop_toBottomOf="#+id/rrr" />
<Spinner
android:id="#+id/spinner2"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="#+id/rrr"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="#+id/rrr"
app:layout_constraintTop_toBottomOf="#+id/textView16" />
<TextView
android:id="#+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/state"
android:textColor="#color/colorPrimary"
app:layout_constraintStart_toStartOf="#+id/spinner2"
app:layout_constraintTop_toBottomOf="#+id/spinner2" />
<Spinner
android:id="#+id/spinner3"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="#+id/spinner2"
app:layout_constraintStart_toStartOf="#+id/spinner2"
app:layout_constraintTop_toBottomOf="#+id/textView18" />
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/city"
android:textColor="#color/colorPrimary"
app:layout_constraintStart_toStartOf="#+id/spinner3"
app:layout_constraintTop_toBottomOf="#+id/spinner3" />
<Spinner
android:id="#+id/spinner4"
style="#style/Widget.AppCompat.Spinner.Underlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="#+id/spinner3"
app:layout_constraintStart_toStartOf="#+id/spinner3"
app:layout_constraintTop_toBottomOf="#+id/textView20" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="#+id/spinner4"
app:layout_constraintStart_toStartOf="#+id/spinner4"
app:layout_constraintTop_toBottomOf="#+id/spinner4">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/location"
android:inputType="text"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/textView24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="#string/map"
android:textColor="#color/colorPrimary"
app:layout_constraintStart_toStartOf="#+id/textInputLayout"
app:layout_constraintTop_toBottomOf="#+id/textInputLayout" />
<include
layout="#layout/activity_maps"
android:layout_width="0dp"
android:layout_height="450dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView24" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Is implementing it like this wrong?
What we did on this scenario was first to add some margin/padding to the map so that the user could scroll on its side.
But then we decided it was better to set that map in the ScrollView not interactive and set an invisible button on the top of it and when the user taps on the button a new activity opened with the map maximised. And there is no scroll in that new activity, the user can only interact with the map or go back.
The fragment which loaded the map was the same, so the code for the map was shared, it's just placed in two different layouts (inside the scrollview without interaction enabled and in the new activity).
Map activities are to be used when you want the map to be the main and pretty much the only thing on your activity. Use a MapFragment instead. Example:
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Related
My code looks good in the activity_main.xml but in the emulator, it lacks the email and password boxes along with the login button. Same happens when run on physical device as well. The screen looks as if there is just a logo and a gray background. This is my first time developing an app so the cause might be even really basic.
This is my xml code right now :
<?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:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A7A5A4"
tools:context=".MainActivity">
<EditText
android:id="#+id/email"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:autofillHints="username"
android:background="#drawable/rounded_text"
android:ems="10"
android:inputType="textEmailAddress"
android:lineSpacingExtra="8sp"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingRight="15dp"
android:paddingBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.625"
tools:ignore="LabelFor"
tools:targetApi="o"
tools:text="#string/email" />
<EditText
android:id="#+id/password"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:autofillHints="password"
android:background="#drawable/rounded_text"
android:ems="10"
android:inputType="textPassword"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingRight="15dp"
android:paddingBottom="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/email"
app:layout_constraintVertical_bias="0.056"
tools:ignore="LabelFor"
tools:targetApi="o"
tools:text="#string/password" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/password"
app:layout_constraintVertical_bias="0.116" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView2"
android:layout_width="410dp"
android:layout_height="309dp"
android:contentDescription="#string/id"
app:srcCompat="#drawable/fulllogo" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
The constraints don't seem to be set up correctly. First of all the email has top and bottom of parent, and the rest all go to the bottom of parent. Then the linear layout doesn't have any constraints at all and it's size is set to match_parent, so that is why it is taking up the entire screen, it is also unnecessary to have the linearlayout. Try removing it the linear layout, then putting these constraints in each one with Top_toBottomOf the view before it, and Bottom_toTopOf the one after it, kinda like this.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#A7A5A4"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="410dp"
android:layout_height="309dp"
android:contentDescription="#string/id"
app:srcCompat="#drawable/fulllogo"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#+id/email"/>
<EditText
android:id="#+id/email"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:autofillHints="username"
android:background="#drawable/rounded_text"
android:ems="10"
android:inputType="textEmailAddress"
android:lineSpacingExtra="8sp"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingRight="15dp"
android:paddingBottom="10dp"
app:layout_constraintTop_toBottomOf="#+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#+id/password"
tools:ignore="LabelFor"
tools:targetApi="o"
tools:text="#string/email" />
<EditText
android:id="#+id/password"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:autofillHints="password"
android:background="#drawable/rounded_text"
android:ems="10"
android:inputType="textPassword"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:paddingRight="15dp"
android:paddingBottom="10dp"
app:layout_constraintTop_toBottomOf="#+id/email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="#+id/button"
tools:ignore="LabelFor"
tools:targetApi="o"
tools:text="#string/password" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Button"
app:layout_constraintTop_toBottomOf="#+id/password"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
If you want more space betweewn specific views use android:layout_marginTop="10dp" and/or marginBottom
My kind information to you. Please must avoid the drag and drop the widgets to the Design pane. It causes multiple unwanted errors while running an app. Just write the design code in text pane, this will help you to learn new things while writing the code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
android:background="#A7A5A4"
tools:context=".MainActivity">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="#string/id"
android:src="#drawable/ic_launcher_background" />
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_text"
android:inputType="textEmailAddress"
android:padding="15dp"
android:layout_marginBottom="20dp"
android:layout_centerVertical="true"
android:hint="#string/email" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rounded_text"
android:inputType="textPassword"
android:padding="15dp"
tools:text="#string/password"
android:layout_marginBottom="20dp"
android:layout_below="#id/email"/>
<Button
android:id="#+id/button"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_below="#id/password"
android:text="#string/Button"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
I hope this is will help you in some way.
So I programmed a simple app with android studio and the layout that is shown in the app when I run it is different than the xml file I designed.
Here is a link of an image of the problem.
https://imgur.com/6JIHSQ7
<?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">
<Button
android:id="#+id/subBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/subBtn"
android:textSize="30sp"
app:layout_constraintBaseline_toBaselineOf="#+id/addBtn"
app:layout_constraintStart_toStartOf="#+id/divBtn" />
<Button
android:id="#+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginBottom="42dp"
android:text="#string/addBtn"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="#+id/multBtn"
app:layout_constraintStart_toEndOf="#+id/subBtn" />
<EditText
android:id="#+id/n1EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:ems="10"
android:hint="#string/number1"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.444"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/n2EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="39dp"
android:ems="10"
android:hint="#string/number2"
android:inputType="textPersonName"
app:layout_constraintStart_toStartOf="#+id/n1EditText"
app:layout_constraintTop_toBottomOf="#+id/n1EditText" />
<Button
android:id="#+id/multBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="108dp"
android:layout_marginRight="108dp"
android:layout_marginBottom="336dp"
android:text="#string/multBtn"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="#+id/divBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="88dp"
android:layout_marginLeft="88dp"
android:layout_marginBottom="336dp"
android:text="#string/divBtn"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/resultTextView"
android:layout_width="174dp"
android:layout_height="73dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/colorPrimaryDark"
android:text="#string/resultView"
android:textColor="#color/colorPrimary"
android:textSize="50sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.455"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/n2EditText"
app:layout_constraintVertical_bias="0.637" />
</androidx.constraintlayout.widget.ConstraintLayout>
I think it might be related to the virtual device i'm using but I don't know if that's the problem.
The problem is, your addBtn and subBtn are not aware of the n2EditText. The addBtn depends on the divBtn and the divBtn is placed 336dp above the bottom edge of the screen.
If you need the addBtn to appear below the n2EditText then you need to add a vertical constraint connecting to the n2EditText. Once your buttons are connected to their immediate top elements, you don't need to add the bottom constraint to the bottom edge of the screen.
Imagine a ConstraintLayout as a collection of widgets hanging down from the top of the screen, each tied to the immediately top elements with the chains called "constraints". You don't need to tie the bottom widget to the ground unless it is required by design.
Here is the modified 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/subBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textSize="30sp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="#+id/n2EditText"
app:layout_constraintStart_toStartOf="#+id/n2EditText"/>
<Button
android:id="#+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textSize="30sp"
app:layout_constraintStart_toEndOf="#+id/subBtn"
app:layout_constraintTop_toTopOf="#+id/subBtn"
android:layout_marginStart="16dp"/>
<EditText
android:id="#+id/n1EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:ems="10"
android:hint="n1"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/n2EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="n2"
android:inputType="textPersonName"
app:layout_constraintStart_toStartOf="#+id/n1EditText"
app:layout_constraintTop_toBottomOf="#+id/n1EditText"/>
<Button
android:id="#+id/multBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textSize="30sp"
app:layout_constraintStart_toEndOf="#+id/divBtn"
android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="#+id/divBtn"/>
<Button
android:id="#+id/divBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textSize="30sp"
app:layout_constraintStart_toStartOf="#+id/subBtn"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="#+id/subBtn"/>
<TextView
android:id="#+id/resultTextView"
android:layout_width="174dp"
android:layout_height="73dp"
android:layout_marginBottom="8dp"
android:background="#color/colorPrimaryDark"
android:text="res"
android:textColor="#color/colorPrimary"
android:textSize="50sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="#+id/divBtn"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Anyway, when you have a lot of widgets, you may have to use a ScrollView to accommodate them all.
Try this
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="#+id/subBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="25dp"
android:layout_marginRight="25dp"
android:text="submit"
android:textSize="30sp"
app:layout_constraintEnd_toStartOf="#+id/addBtn"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/n2EditText" />
<Button
android:id="#+id/addBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:text="add"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/subBtn"
app:layout_constraintTop_toBottomOf="#+id/n2EditText" />
<EditText
android:id="#+id/n1EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:ems="10"
android:hint="1"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.439"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/n2EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginLeft="2dp"
android:layout_marginTop="36dp"
android:ems="10"
android:hint="2"
android:inputType="textPersonName"
app:layout_constraintStart_toStartOf="#+id/n1EditText"
app:layout_constraintTop_toBottomOf="#+id/n1EditText" />
<Button
android:id="#+id/multBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:text="mult"
android:textSize="30sp"
app:layout_constraintStart_toEndOf="#+id/subBtn"
app:layout_constraintTop_toBottomOf="#+id/addBtn" />
<Button
android:id="#+id/divBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:layout_marginEnd="48dp"
android:layout_marginRight="48dp"
android:text="div"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="#+id/subBtn"
app:layout_constraintTop_toBottomOf="#+id/subBtn" />
<TextView
android:id="#+id/resultTextView"
android:layout_width="174dp"
android:layout_height="73dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="#color/colorPrimaryDark"
android:text="resultView"
android:textColor="#color/colorPrimary"
android:textSize="50sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.547"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/divBtn" />
</androidx.constraintlayout.widget.ConstraintLayout>
Probably on your layout editor and phone screen sizes are different. Use ConstraintLayout or some other add constraints to views
I cannot say definitly just looking at image but i think you are using facing problem because of your layout. Use LinearLayout to fix it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" />
<!-- EditText: number1 -->
<!-- EditText Number2 -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- 2 Buttons here -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- 2 Buttons here -->
</LinearLayout>
</LinearLayout>
Some general tips that can help:
Check the constraints if you're using ConstraintLayout or relatives between view if you're using RelativeLayout;
Check the values and the units of views;
Check the screen resolution of your "Preview" pane and Emulator.
If it's possible to provide some additional information about the layout that is used, if these tips didn't help.
In preview pane you can find info about resolutions here:
In the emulator pane you can simple see the sizes in the column:
I am trying to emulate an iOS-like keyboard for my Android app. Simply put, the contents of my activity should scroll behind the keyboard without resizing the spacing (which is what android:windowSoftInputMode="stateHidden|adjustResize" does).
I can achieve a close scroll behavior by making my parent layout a ScrollView (as suggested in Make soft keyboard behave like IOS in Android), but doing so also scrolls my custom action bar (which is an included android.support.v7.widget.Toolbar). Either I am not implementing a custom action bar correctly (so it is always at the top of the screen, ignoring scrolling), or there is some trick to get the soft keyboard to only scroll a resize (and scroll) a specific element to make room for itself.
Hopefully this simple picture illustrates what I'm trying to achieve. In the screen on the right, the actionbar is left untouched and the main content spacin remains the same and the view is scrollable.
This is my custom actionbar layout that I include in my activity.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/primaryRed"
android:elevation="4dp"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="-7dp"
android:contentDescription="#string/back"
android:scaleType="centerInside"
android:src="#drawable/ic_up_unpadded" />
<TextView
android:id="#+id/hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="20dp"
android:text="#string/back"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/theGlassFiles"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="22sp" />
</android.support.v7.widget.Toolbar>
The current view experiment layout is below. I've tried many things, none of which work. The one below is my latest test, which also does not achieve what I am try to get to.
<?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:fitsSystemWindows="true"
tools:context="JoinActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<include
layout="#layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/message"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_marginTop="76dp"
android:gravity="center"
android:lineSpacingExtra="8sp"
android:text="#string/joinMessage"
android:textColor="#color/primaryBlue"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/form"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/message"
app:layout_constraintVertical_bias="0.176">
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/firstNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/middleName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/middleNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/lastNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/town"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/townHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/passwordHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/confirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/confirmPasswordHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<Button
android:id="#+id/joinButton"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="25dp"
android:background="#color/primaryRed"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="22sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
EDIT
Swapping around the parent/children layouts, I achieve something really close to what I'm aiming for. The actionbar always is on top, and the keyboard only resizes the scroll view. However, when I scroll I cannot scroll above the first EditText element. Using the picture, I can only scroll up to the first input, and cannot continue to scroll up and see the green icon. Using my actual XML layout, I cannot scroll to see the TextView component. Here is the updated layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="JoinActivity">
<include
layout="#layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="#id/actionbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="#+id/message"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:gravity="center"
android:lineSpacingExtra="8sp"
android:text="#string/joinMessage"
android:textColor="#color/primaryBlue"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/form"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/message"
app:layout_constraintVertical_bias="0.464">
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/firstNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/middleName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/middleNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/lastNameHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/town"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/townHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/passwordHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/confirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/confirmPasswordHint"
android:inputType="textPersonName" />
<Button
android:id="#+id/joinButton"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="25dp"
android:background="#color/primaryRed"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="22sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</RelativeLayout>
I am simply trying to make a scrollable layout with no luck...
I have no idea why it isn't working, it seems to be exactly as I read online.
The problem here is that the bottom of the included layout is cut of to fit exactly the screen size.
this is my layout xml:
<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"
tools:context=""
tools:layout_editor_absoluteY="81dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="opening game"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<NumberPicker
android:id="#+id/numberPicker2"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="14dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="#+id/GameTitleET"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<EditText
android:id="#+id/GameTitleET"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="153dp"
android:ems="10"
android:hint="Game's name"
android:inputType="textPersonName"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/GameContentET"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="מהלך המשחק"
android:inputType="textMultiLine"
android:maxLines="8"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/DeleteAndMakeYOurOwnButton" />
<Button
android:id="#+id/DeleteAndMakeYOurOwnButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:text="Write your own game"
app:layout_constraintStart_toStartOf="#+id/GameContentET"
app:layout_constraintTop_toBottomOf="#+id/numberPicker2" />
<Switch
android:id="#+id/SendToReviewSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:layout_marginStart="16dp"
android:text="הגש משחק להגשה"
app:layout_constraintBottom_toTopOf="#+id/DeleteAndMakeYOurOwnButton"
app:layout_constraintStart_toStartOf="parent" />
<include
android:id="#+id/include5"
layout="#layout/activity_create_post_methods"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/GameContentET" />
</android.support.constraint.ConstraintLayout></ScrollView>
Do you have any suggestion of what should i do? I also plan to add many more layouts to this main layout and I need it to scroll and show everything flawlessly.
Thank you a lot!
I am using ConstraintLayout to design a sign-up screen. I have put the ConstraintLayout inside a scroll view. The user should be able to scroll and view the whole content even when the keypad is open. This feature works when I am using RelativeLayout but doesn't work when I am using ConstraintLayout. The views which are at the bottom of the screen are being hidden behind the keypad. Following is the layout I am using.
<?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:background="#FFFFFF"
android:paddingTop="23dp"
android:fillViewport="true"
tools:context="com.givhero.activities.LoginActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
tools:context="com.givhero.activities.LoginActivity">
<ImageView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="#drawable/back"
android:tint="#color/colorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="#+id/regEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:text="#string/sign_up_email"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/titles_lists"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/back"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="#+id/nameEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:gravity="left"
android:hint="Name"
android:textColor="#color/dark"
android:textColorHint="#color/dark"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/regEmail"
/>
<View
android:id="#+id/nameDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nameEditText"
/>
<EditText
android:id="#+id/emailEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:gravity="left"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/dark"
android:textColorHint="#color/dark"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nameDivider"
/>
<View
android:id="#+id/emailDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/emailEditText"/>
<Button
android:id="#+id/submitButton"
android:layout_width="0dp"
android:layout_height="62dp"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#drawable/button_theme"
android:enabled="false"
android:text="#string/sign_up"
android:textColor="#FFFFFF"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/emailDivider"
/>
<TextView
android:id="#+id/signUpMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:padding="15dp"
android:text="#string/sign_up_message"
android:textColor="#color/dark80Opacity"
android:textSize="#dimen/medium12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/submitButton"
/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
I have added the following in Manifest.
<activity android:name=".activities.EmailSignupActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
Though it doesn't scroll as expected. Following are the screen shots for better understanding
As you can see I have some text below the EditText fields and signup button. What I am expecting is that the user should be able to scroll to the bottom of the page to see that text even if the keyboard is open. Please check the following screenshot when the keypad is open
I am unable to scroll the view when the keyboard is open.
EDIT
Hey,
If anyone is stuck with this issue and landed here for the answer. I could finally find the solution for it. I couldn't figure out the exact reason for this issue but could figure out what is causing the layout not to scroll. Initially, I have been trying to occupy the whole screen including the status bar for design and used the following in oncreate
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
The above line has caused the issue and once I have removed it, I was able to scroll the layout. I would be happy to find the reason why is the layout not scrolling if we occupy the full screen including the status bar for design.
You have to set the windowSoftInputMode on your Activity on your Manifest file.
android:windowSoftInputMode="stateVisible|adjustResize"
(or android:windowSoftInputMode="stateHidden|adjustResize" if you don't want the keyboard to show when you open the activity)
and make your design of the activity to be like that
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
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">
/* your elements here */
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
You can use the ConstraintLayout within RelativeLayout to use the ScrollView. Give the fillViewport to ScrollView. I just change your code like I use to do. And you should give marginBottom to scroll when keyboard is on. Try it out. Hope it help.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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="#FFFFFF"
android:paddingTop="23dp"
tools:context="com.givhero.activities.LoginActivity">
<ScrollView
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="match_parent"
android:layout_gravity="bottom"
tools:context="com.givhero.activities.LoginActivity">
<ImageView
android:id="#+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:src="#drawable/back"
android:tint="#color/colorPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="#+id/regEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:text="#string/sign_up_email"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/titles_lists"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/back"
tools:layout_editor_absoluteX="0dp"/>
<TextView
android:id="#+id/nameEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:gravity="left"
android:hint="Name"
android:textColor="#color/dark"
android:textColorHint="#color/dark"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/regEmail"
/>
<View
android:id="#+id/nameDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nameEditText"
/>
<EditText
android:id="#+id/emailEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#android:color/transparent"
android:gravity="left"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/dark"
android:textColorHint="#color/dark"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/nameDivider"
/>
<View
android:id="#+id/emailDivider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/emailEditText"/>
<Button
android:id="#+id/submitButton"
android:layout_width="0dp"
android:layout_height="62dp"
android:layout_marginEnd="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:background="#drawable/button_theme"
android:enabled="false"
android:text="#string/signup"
android:textColor="#FFFFFF"
android:textSize="#dimen/base"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/emailDivider"
/>
<TextView
android:id="#+id/signUpMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:padding="15dp"
android:text="#string/sign_up_message"
android:textColor="#color/dark80Opacity"
android:textSize="#dimen/medium12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/submitButton"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</RelativeLayout>
Add this in the manifest for your activity.
android:windowSoftInputMode="stateVisible|adjustResize"