The question is already asked here. But don't have satisfactory answer, so I am asking again.
I have a scrollable user registration form, and a fixed SignUp button at the bottom of the screen. And i need to show SignUp button at bottom only i.e. It shouldn't be scrollable. I am using RelativeLayout as root container.
My View Hierarchy is:
In case of android:windowSoftInputMode="adjustNothing"
When i tap in any of my EditText then the soft keyboard appears but scrollview is not completely scrollable. Space equivalent to keyboard is gone behind the keyboard. Which i want to make scrollable.
In case of android:windowSoftInputMode="adjustPan"
It works a bit better but not exactly the way i want it. It pushes my whole screen upward including toolbar which is not desired.
In case of android:windowSoftInputMode="adjustResize"
It pushes my button upward which is not required at all.
So, please suggest me a solution which i can use to fulfil my requirement.
Here is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
tools:context=".activities.CreateAccountActivity">
<include
android:id="#+id/toolbar"
layout="#layout/app_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar"
android:fillViewport="true"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"><!--android:paddingBottom="#dimen/activity_vertical_margin"-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/ll_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/et_first_name"
style="#style/create_account_edittext"
android:hint="#string/first_name" />
<EditText
android:id="#+id/et_last_name"
style="#style/create_account_edittext"
android:hint="#string/last_name" />
<EditText
android:id="#+id/et_dob"
style="#style/create_account_edittext"
android:hint="#string/date_of_birth" />
<EditText
android:id="#+id/et_email"
style="#style/create_account_edittext"
android:hint="#string/email"
android:inputType="textEmailAddress" />
<EditText
android:id="#+id/et_password"
style="#style/create_account_edittext"
android:hint="#string/password"
android:inputType="textPassword" />
<EditText
android:id="#+id/et_confirm_password"
style="#style/create_account_edittext"
android:hint="#string/confirm_password"
android:inputType="textPassword" />
<LinearLayout
android:id="#+id/ll_terms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/separator_margin"
android:background="#color/et_create_account_bg"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/cb_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="#style/BrandedCheckbox" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:text="#string/accept_terms"
android:textColor="#color/white"
app:font="#string/font_helvetica_normal" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_subscription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/et_create_account_bg"
android:orientation="horizontal"
android:padding="10dp">
<CheckBox
android:id="#+id/cb_subscription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:theme="#style/BrandedCheckbox" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:gravity="center_vertical"
android:text="#string/subscription_details"
android:textColor="#color/white"
app:font="#string/font_helvetica_normal" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btn_create_account"
style="#style/buttonStyle"
android:layout_alignParentBottom="true"
android:text="#string/create_account" />
</RelativeLayout>
</ScrollView>
And my manifest is:
<activity
android:name=".activities.CreateAccountActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar" />
Wrap your layout in a scroll view, since scroll view can have only one child, it would be best for you to wrap your Relative layout in it.
<ScrollView>
<RelativeLayout>
...
</RelativeLayout>
</ScrollView>
Just Don't Use
android:windowSoftInputMode
So that by default it will do nothing to adjust when soft keyboard shows...
So don't use any of them...
Code Exemple
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".ScrollView"
tools:showIn="#layout/activity_scroll_view">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Your Name..."/>
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Father's Name.."/>
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Mothers's Name.."/>
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Email Address.."/>
<EditText
android:id="#+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Mobile No.."/>
<EditText
android:id="#+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Present Address.."/>
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Parmanent Address.."/>
<EditText
android:id="#+id/editText8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="Company Name.."/>
<EditText
android:id="#+id/editText9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText15"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<EditText
android:id="#+id/editText11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"/>
<Button
android:id="#+id/btn_signup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SignUp"/>
</LinearLayout>
</ScrollView>
Code in AndroidMaifest.xml for the activity
<activity
android:name=".ScrollView"
android:label="#string/title_activity_scroll_view"
android:theme="#style/AppTheme.NoActionBar">
</activity>
Related
I am using collapsing toolbar with nested ScrollView in Registration fragment, But the register button at the bottom is not fully displaying for the first time when I click on some edit text and opens keyboard if I scroll to bottom then the button is fully visible.
The image is attached below.
Before opening keyboard
when keyboard opens
After keyboard closed
Here is the xml code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stemiIcon"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<EditText
android:id="#+id/et_reg_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:imeOptions="actionNext"
android:inputType="textPersonName" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stemiIcon"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<EditText
android:id="#+id/et_reg_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone"
android:imeOptions="actionNext"
android:inputType="phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stemiIcon"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<EditText
android:id="#+id/et_reg_dob"
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:cursorVisible="false"
android:editable="false"
android:hint="Date of birth"
android:imeOptions="actionNext"
android:inputType="none"
android:longClickable="false" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stemiIcon"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<EditText
android:id="#+id/et_reg_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
style="#style/StyledTilEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stemiIcon"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<EditText
android:id="#+id/et_reg_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:imeOptions="actionNext"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="15dp"
android:text="Gender"
android:textColor="#color/text_line" />
<com.agiliztech.stepout2play.customviews.AnswerTemplateView
android:id="#+id/answerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/have_diabetes"
android:layout_margin="10dp"
app:clickedColor="#color/selected_gender"
app:colorView="#color/color_white"
app:textBackground="#drawable/text_border_with_color"
app:textColor="#color/selected_gender">
</com.agiliztech.stepout2play.customviews.AnswerTemplateView>
<Button
android:id="#+id/bt_reg_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#color/btn_color"
android:text="REGISTER"
android:textColor="#color/color_white" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
Set height to match_parent and add android:fillViewport element
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:fillViewport="true"/>
...
...
</android.support.v4.widget.NestedScrollView>
Add
android:windowSoftInputTypeMode="adjustResize|stateAlwaysHidden" to activity in your manifest, then make your nestedtscrollview height match parent and fillviewport true in the xml
Try to add android:minHeight to yourCollapsingToolbarLayout
Hi All could someone direct me on how i could align the Spinners and Edit text attached in the screen
Thank you for your help
XML file - below is the layout XML file for the UI screen
<LinearLayout 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:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
tools:context="eudhar.com.eudhar.transaction.MakeTransactionFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Make Transaction"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
style="#style/Base.V7.Widget.AppCompat.EditText"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="#+id/selectCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Select customer"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/selectTransactionType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Select Transaction Type"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_amount"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTextAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Amount in Rs."
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTextTransactionDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Transaction Date"
android:inputType="none"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/buttonAddTrasaction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Transaction" />
</LinearLayout>
Give margin to your Linear /Relative layout, else share your code, so I can easily give you the answer.
Is this okay?
Try this below code, i have given paddingLeft and paddingRight "5dp" to the parent layout itself. You may adjust as you need.
<LinearLayout 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:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingLeft="5dp"
android:paddingRight="5dp"
tools:context="eudhar.com.eudhar.transaction.MakeTransactionFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Make Transaction"
android:textAppearance="#style/Base.TextAppearance.AppCompat.Small"
style="#style/Base.V7.Widget.AppCompat.EditText"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="#+id/selectCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Select customer"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="#+id/selectTransactionType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Select Transaction Type"
style="#style/Base.Widget.AppCompat.Spinner.Underlined"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_amount"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTextAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Amount in Rs."
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTextTransactionDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Transaction Date"
android:inputType="none"
/>
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/buttonAddTrasaction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Transaction" />
</LinearLayout>
So I've been designing in XML in Android Studio a standard log in page - with an image covering about half of the screen, and then the edit text fields occupying the bottom half, asking for the log in details. My problem is that when I tap on the edit text fields on smaller mobile displays, it will only snap to and show the field I have selected, when I think it's far better if it were to automatically snap to show all fields and the 'Next' button at once.
An overview of the page
When I click on 'UserID' field
What I WANT to see when I click on 'UserID' field
How do I achieve this result?
<LinearLayout 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:gravity="center_horizontal"
android:orientation="vertical"
tools:context="com.example.android.brunelplanner.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="250sp"
android:background="#color/colorPrimary"
android:orientation="vertical"></LinearLayout>
<RelativeLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logo"
android:orientation="vertical">
<LinearLayout
android:id="#+id/login_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.87"
android:gravity="center"
android:text="eVision Log in"
android:textColor="#000000"
android:textSize="20sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_userID"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/login_fields">
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/action_sign_in"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Cant comment so I have to write here. If you XML in question is current, you have to align parent bottom the whole layout that you want to move up. The bottom alignment must have the whole login form not just button. Also you have linear layout on top which has fixed height, that could be a problem too.
EDIT: Ok, try this, it works on my end. BUT I simplified the XML for testing so dont copy it, just try to edit your xml.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/email_login_form"
android:layout_alignParentTop="true"
android:background="#color/colorPrimary"
android:orientation="vertical">
</LinearLayout>
<RelativeLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true">
<LinearLayout
android:id="#+id/login_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.87"
android:gravity="center"
android:text="eVision Log in"
android:textColor="#000000"
android:textSize="20sp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/email_login_form"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="sign in"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Hi i am following this link for implementing CustomKeyboard. Everything was perfect except if there are number of EditTexts in my layout. The window is not resizing when the keyboard appears, say if i am trying to enter data to EditTexts which are placed on bottom gets covered by the keyboard. The solutions like adjust resize and adjust pan with the manifest are not working in this case, also i tried with putting ScrollView in layout, but not getting any solution. Please see my layout given below.
<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" >
<EditText
android:id="#+id/edittext0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext0"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext1"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext2"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext3"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext5"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext6"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext7"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<!-- NOTE No need to develop a system service for keyboard, there is a standard View for that (well, not completely standard, its in a funny package 'android.inputmethodservice'. -->
<!-- NOTE The graphical layout does not know the package ('java.lang.NoClassDefFoundError: Could not initialize class android.inputmethodservice.KeyboardView') so the keyboard is not shown. -->
<!-- <android.inputmethodservice.KeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:background="#drawable/normal"/>
-->
<nl.fampennings.keyboard.CustomKeyboardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/keyboardview"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"
android:keyBackground="#drawable/samplekeybackground"/>
Please help me with a solution. Thank you.
OK I got the solution. Please find the modified layout code.
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/edittext0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext0"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext1"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/txt"
android:inputType="text" />
<EditText
android:id="#+id/edittext3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext2"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext3"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext5"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext6"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
<EditText
android:id="#+id/edittext8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edittext7"
android:layout_centerHorizontal="true"
android:drawableRight="#drawable/hex"
android:inputType="text" />
</LinearLayout>
</ScrollView>
<nl.fampennings.keyboard.CustomKeyboardView
android:id="#+id/keyboardview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyBackground="#drawable/samplekeybackground"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
Add a linearLayout as the child of main parent layout; Add a scroll View to that layout with weight 1 and add another layout to the scrollView as the container for child items like EditTexts and all. The keyboard view should be added in the same layout as the scrollView contains. I hope the solution will be helpful for someone.
I have encountered a problem where when i use any theme in the android manifest file the scroll wont happen when the soft keyboard is open, I know this because I removed the Theme and it started working normally this is the layout file code
<?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:orientation="vertical" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<EditText
android:id="#+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<EditText
android:id="#+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<EditText
android:id="#+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<EditText
android:id="#+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<EditText
android:id="#+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
Has anyone encountered such strange issue before, do let me know if there is a work around, as currently I have set Background to all different layouts instead of simply setting it in a theme.
Possibly setting the theme as "full window" and removing "title bar" acts similar to android:windowSoftInputMode="adjustPan" which stops the UI from readjusting