I'm confused why it doesn't scroll down when my cursor focus inside the EditText, in order to scroll you just need to click to the another to scroll down, it there any way how to handle this?
I've Already used this command inside Layout but it doesn't work, need help
android:focusable="true"
android:focusableInTouchMode="true"
**The layout above is the child of this activity so this is the parent it's just like onBoarding Screen using ViewPager
The parent xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Scanner.ScanCashCard">
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</HorizontalScrollView>
<LinearLayout
android:id="#+id/layoutDots"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:orientation="horizontal"
android:background="#color/primary"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView
android:id="#+id/tvPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_marginBottom="25dp"
android:text="PREV"
android:textColor="#android:color/white"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="#+id/tvNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_marginBottom="25dp"
android:text="NEXT"
android:textColor="#android:color/white"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout
android:id="#+id/linear2"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal"
android:padding="5dp"
app:layout_constraintBottom_toBottomOf="parent">
<ImageView
android:id ="#+id/imageIv"
android:height ="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Updated I tried android:fillViewport="true" like in the following but it didn't work
Updated Code
Child xml
<?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:background="#color/primary"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:layout_margin="15dp"
android:textStyle="bold"
android:text="I. Demographics"
android:fontFamily="sans-serif-condensed"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15dp" />
<ScrollView
android:background="#color/white"
android:layout_width="wrap_content"
android:layout_height="660dp"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_hhid"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginRight="10dp"
app:errorEnabled="true"
app:counterEnabled="true"
app:counterMaxLength="30"
app:endIconMode="clear_text"
app:helperText="Search Household ID!"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_hh">
<EditText
android:id="#+id/edtHhId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="160310001-"
android:hint="Household no."
android:inputType="text"
android:maxLength="30" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right">
<Button
android:id="#+id/btnSearchHh"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:padding="10dp"
android:textSize="12dp"
android:text="Search"
android:textStyle="bold"
/>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_fullname"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_search"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_person">
<EditText
android:id="#+id/edtFullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full name:"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_clientstatus"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_fullname"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:helperText="Required"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_client">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="#+id/spinnerClientStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Client status"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_address"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_clientstatus"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_baseline_location_on_24">
<EditText
android:id="#+id/edtAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Address"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/til_sex"
app:helperText="Required"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
app:helperTextTextColor="#color/validation"
android:layout_below="#+id/til_address"
app:startIconDrawable="#drawable/ic_baseline_supervised_user_circle_24"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="#+id/spinnerSex"
android:layout_width= "match_parent"
android:hint="Sex"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_contact_no"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_sex"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_baseline_phone_android_24">
<EditText
android:id="#+id/edtContactNo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Contact No."
android:inputType="number" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_set"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_contact_no"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperText="Required"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_assigned">
<EditText
android:id="#+id/edtSet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Set"
android:inputType="number" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_assigned"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_contact_no"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
app:endIconMode="clear_text"
app:helperTextTextColor="#color/validation"
app:startIconDrawable="#drawable/ic_baseline_person_24">
<EditText
android:id="#+id/edtAssigned"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Assigned C/ML"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/til_minor_grantee"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="80dp"
app:helperTextTextColor="#color/validation"
android:layout_below="#+id/til_assigned"
app:startIconDrawable="#drawable/ic_baseline_escalator_warning_24"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu">
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="#+id/spinnerMinorGrantee"
android:layout_width= "match_parent"
android:hint="Minor Grantee"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
Change the height of the ScrollView like this.
And Also add app:layout_constraintTop_toBottomOf and app:layout_constraintBottom_toBottomOf.
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="#+id/textView1"
app:layout_constraintBottom_toBottomOf="parent">
If first doesn't work, try second one.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:fillViewport="true">
May be this will fix your issue.
Related
I have a layout with different views. I need to move layout with header image (eye) after keyboard appearing. First I have situation like on picture 1
After clicking on Email, all layout is moving, but without header image (eye). Picture 2
Here is my xml file
<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:orientation="vertical">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="66dp"
android:contentDescription="TODO"
android:src="#drawable/ic_eye" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="32dp"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/no_account"
android:gravity="right"
android:layout_marginEnd="4dp"
tools:ignore="RtlHardcoded" />
<TextView
android:layout_marginStart="4dp"
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/registration"
style="#style/TextLink"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:text="#string/entre"
android:textColor="#color/black"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="#style/InputWindow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/emailText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:ellipsize="end"
android:hint="#string/email"
android:maxLines="1"
tools:ignore="KeyboardInaccessibleWidget" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/passwordLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:boxCornerRadiusBottomEnd="5dp"
app:boxCornerRadiusBottomStart="5dp"
app:boxCornerRadiusTopEnd="5dp"
app:boxCornerRadiusTopStart="5dp"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/passwordText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:drawableEnd="#drawable/ic_eye"
android:ellipsize="end"
android:hint="#string/password"
android:inputType="textPassword"
android:maxLines="1"
tools:ignore="KeyboardInaccessibleWidget" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/textView2"
style="#style/TextLink"
android:layout_width="109dp"
android:layout_height="33dp"
android:layout_gravity="right"
android:layout_marginEnd="4dp"
android:gravity="center"
android:text="#string/forgetPassword"
android:textSize="14sp"
tools:ignore="RtlHardcoded" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="51dp"
android:layout_marginTop="16dp"
android:orientation="vertical">
<com.google.android.material.button.MaterialButton
android:id="#+id/entreBtn"
style="#style/ButtonDisable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:enabled="false"
android:text="#string/entire"
app:cornerRadius="5dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
I can not put ImageView into main layout with EditText because ImageView must not be tied with these layouts.
I don't know what to do with this ImageView which did not move upper
The linear layout that holds the views to be below the image view using
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_below="#id/imageView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical"
tools:ignore="UselessParent">... And the rest of your views ...
I'm playing with TextInputEditText and I'm front face a strange issue. When I edit the content of the first one, let's say the "Nom" field, everything looks good, the keyboard appears and I can see the entered text. Now if I need to enter a text in a text field which is under the keyboard, the Activity pans up so the field is in view, but I can NOT see the text that I'm entering... Please have a look at this video: https://www.digitalblend.fr/android_TextInputEditText_issue.mp4
Moreover please have a look at my actual code :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MessageFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="120dp" />
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_last_name"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/lastname"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="textPersonName"
android:nextFocusDown="#+id/firstname"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<View
android:layout_width="10dp"
android:layout_height="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/first_name"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/firstname"
android:layout_width="match_parent"
android:padding="5dp"
android:hint=""
android:maxLines="1"
android:inputType="textPersonName"
app:textInputLayoutFocusedRectEnabled="true"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_mail"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:padding="5dp"
android:hint=""
android:maxLines="1"
android:inputType="textEmailAddress"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_enterprise"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/enterprise"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_code_postal"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/postal_code"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/city"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/city"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/phone_number_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_tel"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="5dp"
android:paddingHorizontal="15dp"
android:maxLines="1"
android:inputType="text"
android:textColor="#color/black"
android:imeOptions="actionDone"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_buy"
android:layout_width="match_parent"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:background="#drawable/little_red_button"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:text="#string/send_demand"
android:gravity="center"
android:textColor="#color/white"
android:textSize="14sp"/>
</LinearLayout>
</ScrollView>
In my manifest I used android:windowSoftInputMode="adjustPan">
If someone has an idea ? Thanks in advance.
I have been getting this "ScrollView can host only one direct child" even though I am only using one main layout in the layout XML code. Basically what I'm trying to do is call/start the RegisterFragment from the LoginFragment. I am trying to do that using the following code:
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.vvLoginBanner: toggleVolume(); break;
case R.id.btnLogin: login(); break;
case R.id.tvSignup: FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.loginFragmentLayout, new RegisterFragment());
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
break;
}
}
Here is the code for both of these XML file that could be possibly causing the error:
LoginFragment.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/loginFragmentContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
tools:context="com.bvmobileapps.bvmobileapps.LoginFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/flBannerProgressBarWrapper"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:background="#color/black"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/pbBanner"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"/>
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/nsvScrollView"
android:layout_below="#id/rlVideoWrapper"
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/loginFragmentLayout"
android:isScrollContainer="true"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/fragmentFrameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:id="#+id/llBannerWrapper"
android:weightSum="100"
android:orientation="horizontal"
android:layout_marginTop="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_weight="10"
android:layout_width="0dp"
android:layout_height="1px"/>
<ImageView
android:id="#+id/ivBanner"
android:src="#drawable/bv_banner"
android:layout_weight="80"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginBottom="#dimen/intra_item_margin"
android:layout_marginTop="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvUsername"
android:hint="#string/username_hint"
android:singleLine="true"
android:maxLength="20"
android:imeOptions="actionNext"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvPassword"
android:hint="#string/password_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:layout_margin="#dimen/inter_item_margin"
android:fontFamily="#font/segoe_ui_semi_bold"
android:text="#string/login_btn"
app:backgroundTint="#color/bv_blue" />
<ProgressBar
android:id="#+id/pbLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-14dp"
android:layout_marginBottom="#dimen/inter_item_margin"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="#+id/tvSignup"
android:text="#string/signup"
android:textSize="#dimen/smallest_text"
android:textColor="#color/bv_blue"
android:textAlignment="center"
android:layout_marginRight="20dp"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/tvForgotPassword"
android:text="#string/forgot_password"
android:textSize="#dimen/smallest_text"
android:textColor="#color/bv_blue"
android:textAlignment="center"
android:layout_marginLeft="0dp"
android:layout_width="150dp"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
RegisterFragment.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/registerFragmentContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
tools:context="com.bvmobileapps.bvmobileapps.RegisterFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="#+id/flBannerProgressBarWrapper"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:background="#color/black"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/pbBanner"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"/>
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/nsvScrollView"
android:layout_below="#id/rlVideoWrapper"
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:isScrollContainer="true"
android:orientation="vertical"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/registerFragmentLayout"
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center_horizontal"
android:weightSum="10"
android:orientation="horizontal">
<ImageView
android:id="#+id/ivValidUsername"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="21dp"
android:layout_marginBottom="#dimen/intra_item_margin"
android:scaleType="fitXY"
android:src="#drawable/red_error" />
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginBottom="#dimen/intra_item_margin"
android:layout_marginTop="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvUsername"
android:hint="#string/username_hint"
android:singleLine="true"
android:maxLength="20"
android:layout_marginLeft="#dimen/inter_item_margin_left"
android:imeOptions="actionNext"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
<include layout="#layout/horizontal_divider"
android:id="#+id/source_divider"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="#id/photo_source_edit_text_wrapper"/>
<RelativeLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center_horizontal"
android:weightSum="10"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/ivValidEmail"
android:layout_gravity="center_horizontal"
android:src="#drawable/red_error"
android:scaleType="fitXY"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvEmail"
android:hint="#string/email_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="text"
android:gravity="start"
android:ellipsize="start"
android:layout_marginLeft="#dimen/inter_item_margin_left"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
<include layout="#layout/horizontal_divider"
android:id="#+id/source_divider"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="#id/photo_source_edit_text_wrapper"/>
<RelativeLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center_horizontal"
android:weightSum="10"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="#+id/ivValidPassword"
android:layout_gravity="center_horizontal"
android:src="#drawable/red_error"
android:scaleType="fitXY"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvPassword"
android:hint="#string/password_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:gravity="start"
android:ellipsize="start"
android:layout_marginLeft="#dimen/inter_item_margin_left"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>
<include layout="#layout/horizontal_divider"
android:id="#+id/source_divider"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="#id/photo_source_edit_text_wrapper"/>
<LinearLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center_horizontal"
android:weightSum="10"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvFirstName"
android:hint="#string/first_name_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="text"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvLastName"
android:hint="#string/last_name_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="text"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/spGender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvZipCode"
android:hint="#string/confirm_password_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:gravity="center_horizontal"
android:weightSum="25"
android:orientation="horizontal">
<TextView
android:id="#+id/tvBirthDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:text="DateTime"/>
</LinearLayout>
<include layout="#layout/horizontal_divider"
android:id="#+id/source_divider"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="1dp"
app:layout_constraintTop_toBottomOf="#id/photo_source_edit_text_wrapper"/>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvSecurityQuestion"
android:hint="#string/secret_question_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="#dimen/inter_item_margin"
android:layout_marginEnd="#dimen/inter_item_margin"
android:layout_marginTop="#dimen/intra_item_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/tvSecurityQuestionAnswer"
android:hint="#string/secret_question_answer_hint"
android:fontFamily="#font/segoe_ui_light"
android:maxLength="20"
android:singleLine="true"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:gravity="start"
android:ellipsize="start"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="#+id/agree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/appbar_padding_top"
android:checked="true"
android:text="#string/checkbox_label_termscond" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btnRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/white"
android:layout_margin="#dimen/inter_item_margin"
android:fontFamily="#font/segoe_ui_semi_bold"
android:text="#string/submit_btn"
app:backgroundTint="#color/bv_blue" />
<ProgressBar
android:id="#+id/pbRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
Here is following error message produced in the logcat:
java.lang.IllegalStateException: ScrollView can host only one direct child
at android.widget.ScrollView.addView(ScrollView.java:273)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1466)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
Now I made sure that in the layout I only include one main layout with other nested layouts included in that main layout. So, based on that I don't think I should be getting that error. Any help or advice to fix this problem would be greatly appreciated!
You are missing a closing tag for your Scroll View in your xml files.
Btw, Consider using nested scroll view instead of scroll view.(As mentioned in the documentation)
Also you should avoid using scroll view inside another scroll view.
Suggestion : Avoid nesting too much to enhance layout performance.
Have a look : Performance and view hierarchies
There must be only one child view in ScrollView. You are getting this error because you are not using the full closing tag.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/loginFragmentContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
tools:context="com.bvmobileapps.bvmobileapps.LoginFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
....
</RelativeLayout>
</ScrollView>
<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:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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="wrap_content"
tools:context="com.example.salu.xyz.SurroundingsPropertyFragment">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="#+id/textView77"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Property Surroundings:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textSize="20sp"/>
<EditText
android:id="#+id/editText55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="textMultiLine"
app:layout_constraintBaseline_toBaselineOf="#+id/textView77"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/textView78"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Class Of Locality:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView77"
android:textSize="20sp"/>
<Spinner
android:id="#+id/spinner9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBaseline_toBaselineOf="#+id/textView78"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText55" />
<TextView
android:id="#+id/textView79"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Proximities to Civic Amenities:"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView78"
android:textSize="20sp"/>
<EditText
android:id="#+id/editText57"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBaseline_toBaselineOf="#+id/textView79"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/spinner9" />
<TextView
android:id="#+id/textView80"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Neighbourhood:"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView79"
android:textSize="20sp"/>
<EditText
android:id="#+id/editText58"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBaseline_toBaselineOf="#+id/textView80"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editText57" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</ScrollView>
Hi, I'm new to Android Application Development, I am creating a form in Fragment which has both TextView and EditText and I was Testing it for 5-inch screens, but the TextViewand EditText got overlapped.
I tried widgets to resize them but the alignment looks bad once I go towards higher screen size.
Is there a way this can be rectified or avoided?
use linearlayout for forms and keep the parent layout to RelativeLayout. Do something like this and your form will be fine on every device:
<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:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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="wrap_content"
tools:context="com.example.salu.libravaluation.SurroundingsPropertyFragment">
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView77"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Property Surroundings:"
android:textSize="20sp" />
<EditText
android:id="#+id/editText55"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textMultiLine" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ll1"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView78"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Class Of Locality:"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner9"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ll2"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView79"
android:layout_width="0dp"
android:layout_weight="1"
android:gravity="center|start"
android:layout_height="match_parent"
android:text="Proximities to Civic Amenities:"
android:textSize="20sp" />
<EditText
android:id="#+id/editText57"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBaseline_toBaselineOf="#+id/textView79" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ll3"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView80"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Neighbourhood:"
android:textSize="20sp" />
<EditText
android:id="#+id/editText58"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Here is a my scrollView xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/myCoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/gradient_toolbar"
android:clickable="true"
android:orientation="vertical">
<ImageView
android:id="#+id/u_back_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="8dp"
android:padding="4dp"
android:src="#mipmap/arrow_back_blue" />
<TextView
android:id="#+id/headerTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="#string/u_my_page"
android:textColor="#ffffff"
android:textSize="16dp" />
<TextView
android:id="#+id/my_profile_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="8dp"
android:gravity="center"
android:padding="8dp"
android:singleLine="true"
android:text="#string/u_save"
android:textColor="#ffffff"
android:textSize="14dp"
android:visibility="gone" />
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical"
>
<LinearLayout
android:id="#+id/user_header_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:gravity="center_vertical"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/u_user_fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:maxLines="1"
android:singleLine="true"
android:textColor="#4d4d4d"
android:textSize="#dimen/u_common_text_size"
/>
</LinearLayout>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical">
<TextView
android:id="#+id/personal_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="30dp"
android:text="#string/u_personal_settings_txt"
android:textColor="#4d4d4d"
android:textSize="16dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#cccccc" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:background="#drawable/selector_edittext_action"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3">
<android.support.design.widget.TextInputEditText
android:id="#+id/first_name_lat"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#null"
android:hint="#string/u_first_name_lat"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3"
android:textCursorDrawable="#null"
android:textSize="16dp"
app:backgroundTint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:background="#drawable/selector_edittext_action"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3">
<android.support.design.widget.TextInputEditText
android:id="#+id/last_name_lat"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#null"
android:hint="#string/u_last_name_lat"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3"
android:textCursorDrawable="#null"
android:textSize="16dp"
app:backgroundTint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:background="#drawable/selector_edittext_action"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3">
<android.support.design.widget.TextInputEditText
android:id="#+id/u_address"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#null"
android:hint="#string/u_address"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3"
android:textCursorDrawable="#null"
android:textSize="16dp"
app:backgroundTint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:background="#drawable/selector_edittext_action"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3">
<android.support.design.widget.TextInputEditText
android:id="#+id/u_gender"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#null"
android:hint="#string/u_gender"
android:imeOptions="actionNext"
android:inputType="textNoSuggestions"
android:textColor="#4d4d4d"
android:textColorHint="#b3b3b3"
android:textCursorDrawable="#null"
android:textSize="16dp"
app:backgroundTint="#android:color/white" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
In my activity's SoftInputMode is adjustNothing.
As i said my scrollview not working.I search about my problem ,one solution is to change adjustResize,but i don't want this solution, because my AppBarLayout layout moving up.
My questions is that, is it a possible to move scrollview at the moment(adjustNothing).I can't show my last edittext when keyboard is showing.
Or,Is it a possible to disable move up AppBarLayout layout in my xml if I use adjustResize or adjustPan ?
Thanks everyone
Here is a solution
Add this line in NestedScrollView 's child Layout
android:descendantFocusability="afterDescendants"
and manifest file
android:windowSoftInputMode="adjustResize"