How to align Ui Components inside linear layout - android

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>

Related

Bottom Sheet Issue

This is what i want to build.
the circular portion will be outside of layout and the rest portion will be transparent as default action
Till now i have achieved.
the circular portion is getting out but the parent layout is not taking any transparency what i need. I have tried to give the transparent color but its not taking. what i need is the blue portion in the second image, i need it transparent just like when dialog appears. But it is taking the color from parent layout.
Any reference will be appreciated.TIA
Here is my layout xml :
<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="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:id="#+id/bottom_layout"
android:background="#color/colorRed"
>enter code here
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_25sdp"
android:background="#color/colorWhite"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_20sdp"
android:layout_marginRight="#dimen/_20sdp"
android:layout_marginTop="#dimen/_45sdp"
android:orientation="vertical">
<TextView
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_7sdp"
android:backgroundTint="#color/colorLightGrayText"
android:gravity="center"
android:hint="#string/settings"
android:inputType="text"
android:singleLine="true"
android:textColor="#color/colorBlackText"
android:textColorHint="#color/colorBlackText"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/_18sdp"
android:textStyle="bold"/>
<CustomTextView
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_10sdp"
android:backgroundTint="#color/colorLightGrayText"
android:gravity="center"
android:hint="#string/login_to_access_settings"
android:inputType="text"
android:singleLine="true"
android:textColor="#color/colorGray"
android:textColorHint="#color/colorGray"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/_15sdp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/userName_Wrapper"
android:layout_width="match_parent"
android:layout_height="#dimen/_50sdp"
android:layout_marginTop="#dimen/_25sdp"
android:textColorHint="#color/colorLightGrayText"
android:theme="#style/TextLabelGray"
app:errorTextAppearance="#style/error_appearance_gray">
<CustomEditText
android:id="#+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorLightGrayText"
android:hint="Username"
android:inputType="text"
android:singleLine="true"
android:textColor="#color/colorGray"
android:textColorHint="#color/colorWhite"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/password_wrapper"
android:layout_width="match_parent"
android:layout_height="#dimen/_50sdp"
android:textColorHint="#color/colorLightGrayText"
android:theme="#style/TextLabelGray"
app:errorTextAppearance="#style/error_appearance_gray">
<CustomEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorLightGrayText"
android:hint="#string/password"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#color/colorGray"
android:textColorHint="#color/colorWhite"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/_14sdp" />
</android.support.design.widget.TextInputLayout>
<CustomTextView
android:id="#+id/logInSettingWrapper"
android:layout_width="match_parent"
android:layout_height="#dimen/_50sdp"
android:layout_marginBottom="#dimen/_20sdp"
android:layout_marginTop="#dimen/_10sdp"
android:background="#drawable/bg_gray_rounded_rect"
android:gravity="center"
android:padding="#dimen/_10sdp"
android:text="#string/login_to_settings"
android:textAllCaps="true"
android:textColor="#color/colorWhite"
android:textSize="#dimen/_16sdp"
android:textStyle="bold" />
<ImageView
android:id="#+id/btn_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="#dimen/_15sdp"
android:layout_marginBottom="#dimen/_15sdp"
android:src="#drawable/cross_pg_bottom_gray" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:layout_marginBottom="-50dp"
android:background="#drawable/bg_bottom_sheet">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/nav_settings" />
</FrameLayout>
</FrameLayout>
</LinearLayout>
you just need to make transparent your blue color layout .I hope it helps you unless you update your xml file.

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

Hide the background of parent layout

This is an alert dialog. I don't want to show the grey coloured portion (at top), which is background of the parent layout; instead that portion should be clear and the previous activity should be shown there as being shown outside the dialog. Also the border of the circular image view be tight with the image. How do I do that? Thanks in advance.
Mylayout.xml
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#727272">
<RelativeLayout
android:id="#+id/card_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardBackgroundColor="#ffffff"
card_view:cardCornerRadius="4dp"
card_view:cardElevation="0dp"
card_view:cardUseCompatPadding="false">
<RelativeLayout
android:id="#+id/rl_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/til_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp">
<TextView
android:id="#+id/tv_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/textView_DoB"
android:paddingTop="10dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:hint="#string/dd_mm_yyyy"
android:textColor="#android:color/black"
android:textAlignment="viewStart"
android:textSize="25sp"
android:background="#drawable/border_date"/>
</android.support.design.widget.TextInputLayout>
<ImageButton
android:id="#+id/ib_DoB_in_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#id/til_date"
android:layout_marginTop="63dp"
android:layout_marginEnd="5dp"
android:background="#mipmap/calendar"
android:contentDescription="#string/calendar_image" />
<TextView
android:id="#+id/textView_DoB_weekday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#id/til_date"
android:layout_marginTop="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:textColor="#android:color/black"
android:textAlignment="viewStart"
android:textSize="20sp"
/>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/til_date"
android:layout_marginTop="10dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/name"
android:inputType="textCapWords" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_name"
android:layout_marginTop="10dp">
<Spinner
android:id="#+id/sp_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/Category">
</Spinner>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_category"
android:layout_marginTop="10dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/et_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/mobile_number_optional"
android:inputType="number"
android:maxLength="13"/>
</android.support.design.widget.TextInputLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/til_mobile"
android:layout_marginTop="10dp">
<TableRow>
<Button
android:id="#+id/btn_discard"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:text="#string/discard" />
<Button
android:id="#+id/btn_save_data"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:text="#string/save" />
</TableRow>
</TableLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/civ_profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:src="#mipmap/ic_person_image"
card_view:civ_border_width="2dp"
card_view:civ_border_color="#ffffff"/>
</RelativeLayout>
add this on your parent xml
android:background="#android:color/transparent"
and add this to your code so the whole alert dialog become transparent
alertDialog.getWindow().setDimAmount(0);

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>

EditText in TextInputLayout lagging

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.

Categories

Resources