Don't hide keyboard in DialogFragment - android

I've DialogFragment and three TextInputLayouts. When I click on the first TextInputLayout then the keyboard opens. And it does not disappear when you click on others TextInputLayout.
getDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
or
android:windowSoftInputMode="stateHidden"
don't work.
How to solve a problem?
My .xml code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskDate"
android:layout_width="130dp"
android:layout_below="#+id/tilDialogTaskTitle"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:inputType="none"
android:focusableInTouchMode="false"
android:cursorVisible="false"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskTime"
android:layout_width="130dp"
android:layout_alignRight="#+id/tilDialogTaskTitle"
android:layout_below="#+id/tilDialogTaskTitle"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:inputType="none"
android:focusableInTouchMode="false"
android:cursorVisible="false"/>
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spDialogTaskPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tilDialogTaskDate"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
</ScrollView>

Related

TextInputEditText with adjustPan - can't see entered text

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.

Scrollview not scrolling in Android (AdjustPan)

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"

RelativeLayoutwith ScrollView and Button is not setting at bottom of the screen

I want that my edit button always shows on the bottom of the screen. Below is my code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/dimen_16dp">
<Button
android:id="#+id/button_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimaryDark"
android:text="#string/edit"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_above="#+id/button_edit">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/name"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_name_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/date_of_birth"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_dob_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_gender_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/gender"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_gender"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="clip_vertical"
android:hint="#string/house_no_sector_street_phase_floor_etc"
android:inputType="textCapSentences"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_address_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/pin_code"
android:inputType="number"
android:maxLength="6"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/til_pin_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/state"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_state_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/mobile_no"
android:inputType="number"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_contact_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/e_mail"
android:inputType="textEmailAddress"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Problem: The problem is that the button does not display on the bottom instead it shows on the top of the screen and ScrollView is not visible at all. If I change match_parent in android:layout_height="match_parent" of the outer RelativeLayout to some value like 500dp then it works ok but as soon as I change it to match_parent the button goes on the top.
Can anyone help me find where I need to be corrected? Thanks
I had put my FrameLayout inside scrollView. and in the layout of fragment I was trying to use again scrollView, therefore, I was facing the issue. I solved it by removing scrollview of framelayout

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" />

Move layout above soft keyboard like edit contacts app

I have the following layout,
<?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"
android:clickable="true"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/name"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/address_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/address_name"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/address"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/street"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/street"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/city"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/state"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/state"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/postal_code"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/postal_code"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/landmark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/landmark"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
When I enter data, the soft keyboard hides the fields. I tried setting android:windowSoftInputMode="adjustPan" in manifest with various setting like adjustNothing, adjustResize etc. These settings never worked.
I want to have the fields scrollable, above the soft keyboard. So data can be entered like default edit contact app in Android.
Tried with Android 5.1

Categories

Resources