EditText in TextInputLayout lagging - android

I have two views using TextInputLayout. The first one is a login view which has only 2 input fields and the second one is a register view which has many input fields. I am using TextInputLayout and EditText/AppCompatEditText with custom themes for my inputs.
The problem is, when i click on my EditText's in my Register screen i get a kind of lag/spikes on the default TextInputLayout animation. I don't get the lag in my LoginScreen but the code I'm using is quite the same, so i suppose the problem is in the number of inputs. Any idea or thoughts?
Here is my register code:
<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="vertical"
tools:context=".activities.MainActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:title="Register as shipper"
app:titleTextColor="#color/white" />
<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"
android:padding="#dimen/space">
<View
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/fullNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_full_name"
android:inputType="text"
android:nextFocusLeft="#id/fullNameEdit"
android:nextFocusUp="#id/fullNameEdit"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/companyNameEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_company_name"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/phoneNumberEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_phone_number"
android:theme="#style/EditText"
android:inputType="phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/emailEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_email"
android:theme="#style/EditText"
android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/passwordEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_password"
android:theme="#style/EditText"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/addressEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/shipper_register_address"
android:theme="#style/EditText"
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/typeSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" />
<Button
android:id="#+id/registerBtn"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="#dimen/space"
android:text="#string/shipper_register_register"
android:theme="#style/ButtonPrimary" />
</LinearLayout>
</ScrollView>
and the login:
<LinearLayout 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:gravity="center"
android:orientation="vertical"
android:padding="#dimen/space">
<ImageView
android:layout_width="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:src="#drawable/logo_color"
android:layout_height="wrap_content" />
<View
android:layout_width="0px"
android:layout_height="0px"
android:focusable="true"
android:focusableInTouchMode="true" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/emailEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/login_email"
android:inputType="textEmailAddress"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#color/hintTextOnLightBackgrounds"
app:hintTextAppearance="#style/TextLabel">
<android.support.v7.widget.AppCompatEditText
android:id="#+id/passwordEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:hint="#string/login_password"
android:inputType="textPassword"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/loginBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/login_login"
android:theme="#style/ButtonPrimary" />
<Button
android:id="#+id/shipperRegisterBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/login_register_as_shipper"
android:theme="#style/ButtonPrimary" />
<Button
android:id="#+id/carrierRegisterBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/login_register_as_carrier"
android:theme="#style/ButtonPrimary" />

I believe that the reason for the lag is that the hint animation of TextInputLayout and the adjustment made to the activity's main window happening at the same time (because of showing soft keyboard).
In my case using android:windowSoftInputMode="adjustNothing" inside the activity tag in Manifest does the job, because it makes keyboard appear over the content without any adjustment made to the activity's main window, however it is up to you to decide if keyboard can overlay your TextInputLayout.
As the last option we can set app:hintAnimationEnabled="false" to the TextInputLayout.

Related

Button is hiding in nested scrollview with collapsing toolbar

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

Bottom view is pushed up when keypad appears

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>

How to align Ui Components inside linear layout

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>

Edit text fields snapping into view

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>

Android remove EditText selection

I have 2 editTexts, whenewer I launch app first(orange) edit text is getting selected automaticaly.
I tried clear focus, but this hadn't worked for me.
<LinearLayout
style="#style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textPersonName"
android:hint="#string/edit_text_title" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/txtInputLayoutPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/event_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textMultiLine"
android:hint="#string/edit_text_description" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
How to make first edit text look like second ?
<LinearLayout
style="#style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/event_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textPersonName"
android:hint="#string/edit_text_title" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/txtInputLayoutPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/event_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="textMultiLine"
android:hint="#string/edit_text_description" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
Make the ViewGroup focusable in touch mode.
Like this from your code:
<LinearLayout
style="#style/Widget.CardContent"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Categories

Resources