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
Related
I am very new to Kotlin and I want to create a simple activity where details of a person are shown with their picture.
I want to move the edit button on top of the imageView so it looks a bit better and is not in line with the other elements. The screenshot is also attached below the XML file
here is my XML file for this layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingVertical="16dp"
tools:context=".EditProfileActivity">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:srcCompat="#android:drawable/ic_menu_camera" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="257dp"
app:srcCompat="#drawable/ic_baseline_person_24" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2">
<EditText
android:background="#CFC9C9"
android:id="#+id/txtEditFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text=""
android:hint="Full Name"
android:textAppearance="#style/TextAppearance.AppCompat.Display1"/>
<EditText
android:background="#CFC9C9"
android:id="#+id/txtEditNickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:text=""
android:hint="Nickname"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"/>
<EditText
android:background="#CFC9C9"
android:id="#+id/txtEditEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:text=""
android:hint="Email(john#abc.com)"
android:textAppearance="#style/TextAppearance.AppCompat.Medium"/>
<EditText
android:background="#CFC9C9"
android:id="#+id/txtEditLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:text=""
android:hint="Location"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
<EditText
android:background="#CFC9C9"
android:id="#+id/txtEditSkills"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:text=""
android:hint="Skills"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
<EditText
android:background="#CFC9C9"
android:inputType="text"
android:id="#+id/txtEditDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingVertical="5dp"
android:layout_marginVertical="2dp"
android:hint="Description"
android:text=""
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#+id/imageView"
app:layout_constraintEnd_toEndOf="#+id/imageView"
app:layout_constraintStart_toStartOf="#+id/imageView"
app:layout_constraintTop_toTopOf="#+id/imageView"
app:srcCompat="#android:drawable/ic_menu_camera" />
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="257dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/ic_baseline_person_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
It's impossible to stack the views in LinearLayout. In LinearLayout you can only place the views in a row/column. If u need to place one view over another, u should use FrameLayout (simpliest variant) or ConstraintLayout
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"
In my layout i have some edit text and a scroll view.The problem is when I touch the edit text the soft keyboard is open but if i try to scroll down it is not scrolling down fully. Same case happen when i try to scroll up fully.
But if i use android : windowSoftInputMode="adjustresize" i can scroll fully up but my keyboard hide the bottom edit text.I also try to use
android : windowSoftInputMode="adjustspan|adjustresize" but no solution found.
Another problem is that I show some error message when user try to input same text if it is match but when close the soft keyboard the message is not attaching with its right position.
its my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >
<include
android:id="#+id/toolbar"
layout="#layout/toolabar"
android:theme="#style/mycustomtoolbartheme"></include>
<ScrollView
android:id="#+id/scrollView_addproductactivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
>
<LinearLayout
android:id="#+id/activity_add_product"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:id="#+id/btn_save_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:background="#drawable/shape1"
android:text="Save"
android:textColor="#fff" />
<Button
android:id="#+id/btn_view_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:background="#drawable/shape1"
android:text="view"
android:textColor="#fff" />
</RelativeLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitePn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Product Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocompliteBn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Brand Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_MN"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Model Num"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Quantity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Quantity"
android:imeOptions="flagNoExtractUi"
android:inputType="number"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_PPP"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Price per Pice"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitecn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Country "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitecolor_name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Color "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_ProductSize"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Size"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocompliteDname"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Delleremail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Email"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_DellerPhn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Phn Num"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Delleradd"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Add"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Dellerfax"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Fax"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
i add this code to my manifest file but no solution found
<activity
android:name="com.example.oggy.productcatalog.AddProductActivity"
android:windowSoftInputMode="adjustPan"
/>
If you are fine with layout not adjusting
<activity android:name="com.example.oggy.productcatalog.AddProductActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />
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>
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" />