Scrollview not scrolling in Android (AdjustPan) - android

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"

Related

Scrollview not working when focus in EditText on Android studio

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.

android scrollview not working with cardView and with noActionBar theme

Below xml contains a ScrollView and a Cardview but scrolling is not working for the ScrollView. I have added below line in manifest for below layout:
<activity android:windowSoftInputMode="adjustPan"
android:name=".activities.RegisterActivity" />
Can anyone help me to fix this issue?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/relative"
android:layout_width="match_parent"
android:layout_height="#dimen/margin_400dp"
android:layout_margin="#dimen/margin_10dp">
<android.support.v7.widget.CardView
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
app:cardBackgroundColor="#color/white"
app:cardCornerRadius="#dimen/margin_5dp"
app:cardElevation="#dimen/margin_20dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin_10dp"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/margin_10dp"
android:src="#drawable/user_default" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_10dp"
android:textColorHint="#color/blue">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="#dimen/margin_50dp"
android:hint="#string/Email"
android:inputType="textEmailAddress"
android:textColor="#color/blue"
android:textColorHint="#color/blue"
android:theme="#style/MyEditTextTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/blue">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="#dimen/margin_50dp"
android:hint="#string/Name"
android:inputType="text"
android:textColor="#color/blue"
android:textColorHint="#color/blue"
android:theme="#style/MyEditTextTheme" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Password"
android:textColorHint="#color/blue"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#color/blue">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="#dimen/margin_50dp"
android:hint="#string/Password"
android:inputType="textPassword"
android:textColor="#color/blue"
android:textColorHint="#color/blue"
android:theme="#style/MyEditTextTheme" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/btn_signup"
android:layout_width="#dimen/margin_120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/relative"
android:layout_gravity="bottom|center"
android:layout_marginRight="#dimen/margin_60dp"
android:layout_marginTop="#dimen/margin_m65dp"
android:background="#drawable/rounded_textview"
android:gravity="center"
android:padding="#dimen/margin_10dp"
android:text="#string/Sign_up"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/relative"
android:layout_centerHorizontal="true"
android:layout_marginBottom="#dimen/margin_10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/margin_10dp"
android:text="#string/already_have_an_account"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:padding="#dimen/margin_5dp"
android:text="#string/Login"
android:textColor="#color/blue"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Use android.support.v4.widget.NestedScrollView instead of ScrollView.

Layout not adjust when keyboard opens

Hi i have the following layout in activity.xml file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_change_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
tools:context="com.kdpl.motodriver.ChangePassword">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_width="fill_parent"
android:layout_height="58dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:titleTextColor="#ffffff">
<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/back_arrow" android:onClick="onBackPressed" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/change_password_header"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
style="#style/TitleStyle"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_below="#+id/toolbar1"
android:id="#+id/txt1">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:id="#+id/txtOldPIN"
android:hint="#string/txt_old_pin"
android:maxLength="4"
android:paddingLeft="10dp"
android:textColor="#ffffff"
android:inputType="numberPassword"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/txt1"
android:id="#+id/txt2">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:paddingLeft="10dp"
android:textColor="#ffffff"
android:id="#+id/txtNewPin"
android:inputType="numberPassword"
android:maxLength="4"
android:hint="#string/txt_new_pin"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/txt2"
android:id="#+id/txt3">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:paddingLeft="10dp"
android:id="#+id/txtConfirmPin"
android:inputType="numberPassword"
android:maxLength="4"
android:textColor="#ffffff"
android:layout_below="#+id/txt2"
android:hint="#string/txt_confirm_new_pin"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btnChangePIN"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_centerHorizontal="true"
android:background="#drawable/my_custom_btn_1"
android:layout_below="#id/txt3"
style="#style/buttonStyle"
android:text="#string/txt_change_pin"
android:enabled="false"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btnCancelPIN"
android:layout_marginTop="20dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_centerHorizontal="true"
android:background="#drawable/my_custom_btn_1"
android:layout_below="#id/btnChangePIN"
style="#style/buttonStyle"
android:text="#string/btn_cancel_text" />
</LinearLayout>
I have added the following line in Manifest.xml
<activity android:name=".ChangePassword"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
/>
But the Buttons align parent bottom hides when keyboard open. Layout does not resize itself.
What i am missing ?
Updated View
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_change_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
tools:context="com.kdpl.motodriver.ChangePassword">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar1"
android:layout_width="fill_parent"
android:layout_height="58dp"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:titleTextColor="#ffffff">
<Button
android:layout_width="25dp"
android:layout_height="25dp"
android:background="#drawable/back_arrow" android:onClick="onBackPressed" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/change_password_header"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
style="#style/TitleStyle"/>
</android.support.v7.widget.Toolbar>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/toolbar1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/toolbar1"
android:id="#+id/txt1">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:id="#+id/txtOldPIN"
android:hint="#string/txt_old_pin"
android:maxLength="4"
android:paddingLeft="10dp"
android:textColor="#ffffff"
android:inputType="numberPassword"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/txt1"
android:id="#+id/txt2">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:paddingLeft="10dp"
android:textColor="#ffffff"
android:id="#+id/txtNewPin"
android:inputType="numberPassword"
android:maxLength="4"
android:hint="#string/txt_new_pin"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_below="#+id/txt2"
android:id="#+id/txt3">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:paddingLeft="10dp"
android:id="#+id/txtConfirmPin"
android:inputType="numberPassword"
android:maxLength="4"
android:textColor="#ffffff"
android:layout_below="#+id/txt2"
android:hint="#string/txt_confirm_new_pin"
android:textColorHint="#color/lightGray"
android:gravity="center_vertical"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:layout_alignParentBottom="true">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btnChangePIN"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_centerHorizontal="true"
android:background="#drawable/my_custom_btn_1"
android:layout_below="#id/txt3"
style="#style/buttonStyle"
android:text="#string/txt_change_pin"
android:enabled="false"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btnCancelPIN"
android:layout_marginTop="20dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_centerHorizontal="true"
android:background="#drawable/my_custom_btn_1"
android:layout_below="#id/btnChangePIN"
style="#style/buttonStyle"
android:text="#string/btn_cancel_text" />
</LinearLayout>
I have updated my view to add scrollview in between toolbar and buttons. I have also added getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); in my activity as suggested.. It works but not perfectly. Now Buttons overlap the views in scroll view. Attached is image
Add parent layout is Scroll view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</ScrollView >
An alternate answer would be to add
android:windowSoftInputMode="adjustResize"
in your root layout
Why not use the CoordinateLayout as the parent layout. If it can work for snacks it must work for the keyboard as well
Add this code in your Activity:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Please use adjustPan instead of adjustResize as follows :
<activity android:name=".ChangePassword"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />

How to Place a FAB at the end of a View?

I'm trying to create a layout like below.
The problem is that the FAB is changing position in some devices because i have hardcoded the bottom margin.
I want the FAB as like in the below image.
PRESENT CODE
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/mlogin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:elevation="8dp"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="30dp"
android:orientation="vertical">
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:src="#drawable/selfiel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Login"
android:textAlignment="center"
android:textColor="#color/colorAccent"
android:textSize="22sp" />
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/forgot"
android:layout_centerHorizontal="true"
android:layout_marginBottom="103dp"
android:src="#drawable/ic_done" />
<TextView
android:id="#+id/forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/submit"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:text="Forgot password?"
android:textColor="#color/white"
android:textSize="18sp" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="20dp"
android:background="#color/colorAccent"
android:onClick="submit"
android:text="Sign Up"
android:textColor="#color/white"
android:textSize="18sp" />
</RelativeLayout>
</RelativeLayout>
You probably want to use the CoordinatorLayout.
The basic layout would be as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/mlogin">
<android.support.v7.widget.CardView
android:id="#+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="30dp"
android:elevation="8dp"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:orientation="vertical">
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="10dp"
android:src="#drawable/selfiel" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Login"
android:textAlignment="center"
android:textColor="#color/colorAccent"
android:textSize="22sp" />
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
<!-- Password Label -->
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp">
<EditText
android:id="#+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:textColor="#color/white" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom">
<TextView
android:id="#+id/forgot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Forgot password?"
android:textColor="#color/white"
android:textSize="18sp" />
<android.support.v7.widget.AppCompatButton
android:id="#+id/submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="Sign Up"
android:onClick="submit"
android:background="#color/colorAccent"
android:textColor="#color/white"
android:textSize="18sp"
android:layout_gravity="bottom|center_horizontal" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_done"
app:layout_anchor="#id/card"
app:layout_anchorGravity="bottom|center"/>
</android.support.design.widget.CoordinatorLayout>
The magic lines here are in the FloatingActionButton that say:
app:layout_anchor="#id/card"
app:layout_anchorGravity="bottom|center"
This essentially tells your layout that the FAB is related to the card, and that it should be positioned relative to the card (centered at the bottom).
You can find the CoordinatorLayout documentation here, and a pretty good tutorial here.
Best of luck!
use android:layout_gravity="bottom" instead Then adjust with margins if you want. so you can do this:
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/forgot"
android:layout_centerHorizontal="true"
android:layout_marginBottom="13dp"
android:layout_gravity="bottom"
android:src="#drawable/ic_done" />

Android ScrollView not working properly when use toolbar

I developed an android application in which the scroll-view is not scrolling.. I am posting the code here pls check and if found any error pls help.. Here I used RelativeLayout as root and then Scroll-view and Relative Layout inside the scroll-view and ... Edit text ans Spinner inside relative layout... but this is not scrolling up..
This is my XML :-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<LinearLayout
android:id="#+id/ll1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="#+id/tool_bar"
layout="#layout/app_bar" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none"
android:layout_above="#+id/btnAccept"
android:layout_below="#+id/ll1"
>
<RelativeLayout
android:id="#+id/rel_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<TextView
android:id="#+id/txvPanmain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="WANT TO GET IN TOUCH WITH US?"
android:textColor="#131517"
android:textSize="18sp"
android:textStyle="bold" />
<android.support.design.widget.TextInputLayout
android:id="#+id/floatedtFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txvPanmain"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Full Name"
android:inputType="textCapSentences"
android:textColor="#android:color/black"
android:textColorHint="#ff0000"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spinCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/floatedtFullName"
android:layout_marginTop="15dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspincountry"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinCountry"
android:layout_marginTop="2dp"
android:background="#000000" />
<Spinner
android:id="#+id/spinCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspincountry"
android:layout_marginTop="15dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspincity"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinCity"
android:layout_marginTop="2dp"
android:background="#000000" />
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspincity"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Email id"
android:inputType="textEmailAddress"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_mobileno"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/float_edit_email"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:hint="Mobile no."
android:inputType="phone"
android:maxLength="10"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spinFeedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/float_edit_mobileno"
android:layout_marginTop="10dp"
android:entries="#array/country"
android:prompt="#string/addressProof" />
<View
android:id="#+id/vspinFeedback"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="#+id/spinFeedback"
android:layout_marginTop="2dp"
android:background="#000000" />
<android.support.design.widget.TextInputLayout
android:id="#+id/float_edit_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/vspinFeedback"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/edtComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:focusable="true"
android:inputType="text"
android:hint="Comments"
android:lines="3"
android:maxLines="3"
android:textColor="#android:color/black"
android:textColorHint="#A4A4A4"
android:textSize="18sp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/btnAccept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/red"
android:layout_alignParentBottom="true"
android:padding="5dp"
android:text="SUBMIT"
android:textColor="#color/white_color"
android:textSize="20sp"
android:textStyle="normal" />
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
This is my app_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar 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="wrap_content"
android:background="#color/colorPrimary"
android:paddingTop="#dimen/app_bar_top_padding"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/Base.ThemeOverlay.AppCompat.Dark.ActionBar">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="22sp"
android:textColor="#android:color/white"
android:textStyle="bold"
android:text="Toolbar Title" />
</android.support.v7.widget.Toolbar>
Your ScrollView has to be a defined height. Try match_parent instead of wrap_content. When a ScrollView wraps its contents there is nothing beeing clipped of you might be able to scroll to.

Categories

Resources