Really frustrating bug that I'm getting. I'm trying to have a login page where I can swap between signing in and signing up. View flipper looked perfect. But for some reason, when I switch from the first layout to the second in the viewflipper, the second layout is "pushed" up. See pictures below (the screen with the red info placeholder icon is the first screen). The "Title" textview is supposed to be in the same position on the second screen as it is on the first. The only way I can make it visible is to give it something like 60dp margin top. Which is what leads me to say that the second layout is "pushed" up.
Below is the xml code for my view flipper. I suppose I can post the xml for the two screens if requested, but it doesn't seem to be an issue with the layouts themselves. I say this because when I swap the order then the screen that previously was pushed up is fine and then the previously good screen is pushed up. So it seems clear it is something wrong with the view flipper. Both the layouts in the viewflipper are relative layouts that are set to match_parent.
<androidx.constraintlayout.widget.ConstraintLayout 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:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/login_gradient"
android:orientation="vertical">
<ViewFlipper
android:id="#+id/view_flipper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:measureAllChildren="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include
android:id="#+id/sign_in_layout"
layout="#layout/sign_in_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<include
android:id="#+id/sign_up_layout"
layout="#layout/sign_up_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>
</androidx.constraintlayout.widget.ConstraintLayout>
First page xml
<?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:id="#+id/sign_in_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#drawable/login_gradient"
android:clickable="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/sign_in_app_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="#font/roboto"
android:text="Title"
android:textColor="#color/notification_color"
android:textSize="36sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/sign_in_app_logo"
android:layout_width="185dp"
android:layout_height="140dp"
android:layout_below="#+id/sign_in_app_title"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:contentDescription="App Logo"
app:srcCompat="#drawable/about_icon" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_in_username_input_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_in_app_logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:backgroundTint="#android:color/white"
android:hint="#string/username_and_email_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_in_username_input"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/user_icon_login"
android:drawablePadding="5dp"
android:inputType="textEmailAddress"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_in_password_input_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_in_username_input_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:backgroundTint="#android:color/white"
android:hint="#string/password_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_in_password_input"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/password_icon"
android:drawablePadding="5dp"
android:inputType="textPassword"
android:longClickable="false"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/sign_in_primary_btn"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/sign_in_password_input_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#50000000"
android:foreground="?android:selectableItemBackground"
android:text="#string/sign_in" />
<View
android:id="#+id/divider"
android:layout_width="300dp"
android:layout_height="2dp"
android:layout_below="#id/sign_in_primary_btn"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#c0c0c0" />
<Button
android:id="#+id/sign_in_change_mode_btn"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#50000000"
android:foreground="?android:selectableItemBackground"
android:text="#string/sign_up" />
</RelativeLayout>
Second page xml
<?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:id="#+id/sign_up_relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="#drawable/login_gradient"
android:clickable="true"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="#+id/sign_up_app_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:fontFamily="#font/roboto"
android:text="title"
android:textColor="#color/notification_color"
android:textSize="36sp"
android:textStyle="bold" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_up_email_input_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_app_title"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:hint="#string/email_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_up_email_input"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/email_icon"
android:drawablePadding="5dp"
android:inputType="textEmailAddress"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_up_username_input_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_email_input_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:backgroundTint="#android:color/white"
android:hint="#string/username_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_up_username_input"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/user_icon_login"
android:drawablePadding="5dp"
android:inputType="textEmailAddress"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_up_password_input_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_username_input_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:backgroundTint="#android:color/white"
android:hint="#string/password_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_up_password_input"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/password_icon"
android:drawablePadding="5dp"
android:inputType="textPassword"
android:longClickable="false"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="#+id/sign_up_password_attributes_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_password_input_layout"
android:layout_alignStart="#+id/sign_up_password_input_layout"
android:layout_alignEnd="#+id/sign_up_password_input_layout"
android:orientation="vertical">
<TextView
android:id="#+id/sign_up_password_length_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:text="#string/password_length_msg"
android:textColor="#color/password_constraint_successful_match"
android:textStyle="bold" />
<TextView
android:id="#+id/sign_up_password_lowercase_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:text="#string/password_lowercase_msg"
android:textColor="#color/password_constraint_unsuccessful_match"
android:textStyle="bold" />
<TextView
android:id="#+id/sign_up_password_uppercase_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:text="#string/password_uppercase_msg"
android:textStyle="bold" />
<TextView
android:id="#+id/sign_up_password_numbers_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:text="#string/password_numbers_msg"
android:textStyle="bold" />
<TextView
android:id="#+id/sign_up_password_special_chars_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/roboto"
android:text="#string/password_special_chars_msg"
android:textStyle="bold" />
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/sign_up_password_confirm_layout"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#+id/sign_up_password_attributes_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:backgroundTint="#android:color/white"
android:hint="#string/password_confirm_hint"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
app:hintTextAppearance="#style/LoginHintStyle"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/sign_up_password_input_confirm"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:backgroundTint="#android:color/white"
android:drawableStart="#drawable/password_icon"
android:drawablePadding="5dp"
android:inputType="textPassword"
android:longClickable="false"
android:textColor="#color/notification_color"
android:textColorHint="#android:color/white"
android:textCursorDrawable="#null"
android:theme="#style/Login.EditText"
android:visibility="visible" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/sign_up_primary_btn"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/sign_up_password_confirm_layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#50000000"
android:foreground="?android:selectableItemBackground"
android:text="#string/sign_up" />
<View
android:id="#+id/divider"
android:layout_width="300dp"
android:layout_height="2dp"
android:layout_below="#id/sign_up_primary_btn"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#c0c0c0" />
<Button
android:id="#+id/sign_up_change_mode_btn"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_below="#id/divider"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="#50000000"
android:foreground="?android:selectableItemBackground"
android:text="#string/sign_in" />
</RelativeLayout>
In classic software engineering fashion, the issue was resolved by adding one line to the layout that houses my viewflipper.
android:fitsSystemWindows="true"
Related
im new to android and java, this is my 1st building login page for my project app, confuse with android studio layout,
My login page username text and password text position are different! anyone have any suggestion for my coding?
<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"
android:gravity="center"
tools:context=".MainActivity"
tools:ignore="ExtraText">
<ImageView
android:id="#+id/item_image"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="#drawable/eschool"
app:layout_constraintBottom_toTopOf="#+id/title" />
<TextView
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="PLT MUAR 行政系统"
android:textColor="#color/black"
android:textSize="35dp"
android:textStyle="bold" />
<TextView
android:id="#+id/ID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="126dp"
android:gravity="left"
android:text="用户名 UserID:"
android:textColor="#color/black"
android:textSize="16sp"
android:textStyle="bold"
tools:ignore="RtlHardcoded" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="55dp"
android:gravity="left"
android:layout_marginTop="5dp"
android:background="#drawable/login_column">
this my username text part:
<EditText
android:id="#+id/et_username"
android:layout_width="340dp"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:textSize="20sp"
android:background="#android:color/transparent"
android:selectAllOnFocus="true"
android:inputType="text|textUri"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
This my password part below:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="密码 Password:"
android:textColor="#color/black"
android:textSize="16sp"
android:layout_marginTop="10dp"
android:layout_marginRight="124dp"
android:textStyle="bold" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="355dp"
android:layout_height="60dp"
android:layout_marginBottom="0dp"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/et_password"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="0dp"
android:inputType="textPassword"
android:background="#drawable/login_column"
android:selectAllOnFocus="true"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="#+id/bt_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#drawable/round_button"
android:text="Submit"
android:textColor="#android:color/white" />
Picture here
any better suggestion for my front page?
this is because for password you use TextInputLayout with TextInputEditText and for username you use EditText, for username instead EditText use TextInputLayout with TextInputEditText as in password example:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="355dp"
android:layout_height="60dp"
android:layout_marginBottom="0dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/et_username"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="0dp"
android:background="#drawable/login_column"
android:selectAllOnFocus="true"
android:textColor="#android:color/black"
android:textColorHint="#android:color/black"
android:textSize="20sp" />
</com.google.android.material.textfield.TextInputLayout>
I am new to designing layouts , and i am trying to make this layout resizable with
android:windowSoftInputMode="adjustResize"
everything is working perfectly but the problem is i can't get the last relative layout to go all the way to the bottom
i tried to set gravity to bottom but it did not work
i added a line in my code where my problem occurs
here is my activity layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="#000000"
tools:context=".testLayout">
<RelativeLayout
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/logoLayout"
>
<ImageView
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:background="#drawable/nlogo">
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/logoLayout1"
android:layout_below="#id/logoLayout"
>
<EditText
android:id="#+id/testUsernameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Username"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testPasswordText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Password"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testEmailText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Email"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<EditText
android:id="#+id/testFullNameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:background="#drawable/rounded_background"
android:gravity="center_vertical"
android:hint="Full Name"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/white"
android:textColorHint="#color/hint_color"
android:textCursorDrawable="#null"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:text="Sign Up"
android:background="#drawable/rounded_button"
/>
</LinearLayout>
<!-- here is the problem -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logoLayout1"
android:id="#+id/footerLayout"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:text="Welcome to ....."
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
many thanks in advance
I have tried your layout in my temporary activity and adding android:fillViewport="true" in the ScrollView worked for me.
Here is the solution:
Add this line in Manifest file for your activity
android:windowSoftInputMode="adjustResize"
I have bit modified the XML file code to make it very easy to read and less view hierarchy.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:fillViewport="true">
<LinearLayout
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="140dp"
android:layout_height="35dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:background="#drawable/ic_eye"
android:contentDescription="#null" />
<EditText
android:id="#+id/testUsernameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="48dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Username"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testPasswordText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Password"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testEmailText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Email"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<EditText
android:id="#+id/testFullNameText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="50dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="50dp"
android:gravity="center_vertical"
android:hint="Full Name"
android:paddingStart="10dp"
android:text=""
android:textColor="#color/colorTextWhite"
android:textColorHint="#color/colorTextBlue"
android:textCursorDrawable="#null"
android:textSize="18sp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="50dp"
android:background="#drawable/shape_calendar_bg"
android:text="Sign Up" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:text="Welcome to ....."
android:textColor="#color/colorTextWhite"
android:textSize="15sp" />
</LinearLayout>
</ScrollView>
While the keyboard is open
As Edittext it is not the only one in the group widget. With TextInputLayout the hint didn't work. Tell me is there any way else to summon help?
This is my layout:
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:textColorHint="#color/colorTextHint">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact"
android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
</RelativeLayout>
</android.support.design.widget.TextInputLayout>
Do like this
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true" app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account_tint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/colorTextHint"
android:maxLines="1"
android:theme="#style/EditText"
android:textSize="16sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_weight="1"
app:hintEnabled="true"
app:hintAnimationEnabled="false"
android:textColorHint="#color/colorTextHint">
<EditText
android:id="#+id/et_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:drawableRight="#mipmap/ic_selectcontact" android:hint="#string/enter_phone_number_contact_name"
android:inputType="text"
android:maxLines="1"
android:textColorHint="#color/colorTextHint"
android:textSize="16sp"
android:theme="#style/EditText" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/et_account_button"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#android:color/transparent"
android:onClick="#{presenter::onClick}"
android:textSize="16sp"
tools:ignore="LabelFor" />
I have a DialogFragment with EditTexts in it. When I open it, the keyboard pops up and hides half of the dialog. Because of that I've used getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); inside the onCreateView. The dialog will resize all right, but it is not scrollable, so I can't get to the other EditTexts and button.
Here's my XML:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/iv_logo_image"
android:layout_width="200dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
app:srcCompat="#drawable/logo" />
<LinearLayout
android:id="#+id/ll_register_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/iv_logo_image"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/screen_edge_margin"
android:orientation="vertical">
<EditText
android:id="#+id/et_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/first_name"
android:inputType="text"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
<EditText
android:id="#+id/et_last_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/last_name"
android:inputType="text"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
<EditText
android:id="#+id/et_company_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/company_name_hint"
android:inputType="text"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
<EditText
android:id="#+id/et_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/username"
android:inputType="textEmailAddress"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
<EditText
android:id="#+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/password"
android:inputType="textPassword"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
<EditText
android:id="#+id/et_confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#drawable/drawable_border"
android:hint="#string/confirm_password"
android:inputType="textPassword"
android:padding="5dp"
android:textColorHint="#color/gray_400"
android:textSize="14sp" />
</LinearLayout>
<TextView
android:id="#+id/tv_register_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/ll_register_form"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:text="Already registered? Login me!"
android:textColor="#color/light_blue_900"
android:textSize="14sp" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tv_register_now"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:background="#drawable/selector_button_blue"
android:text="#string/btn_register"
android:textColor="#color/white"
android:textSize="#dimen/medium_14" />
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</ScrollView>
In activity add android:windowSoftInputMode="adjustResize" in manifest
<activity android:name="YourActivity"
android:windowSoftInputMode="adjustResize" />
I have simple RelativeLayout with multiple elements. But the display is not as expected with some elements jumbled and on top of each other. It seems very strange to me and I am unable to figure out why it is so. Please see the screenshot attached.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp" >
<Button
android:id="#+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:text="Close" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add a missing Business"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#21759b"
android:layout_below="#+id/btnClose"
android:layout_centerHorizontal="true"/>
<Spinner
android:id="#+id/spinnerContactType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:minWidth="250dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_below="#+id/title"
android:entries="#array/contactType" />
<android.support.design.widget.TextInputLayout
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/spinnerContactType" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/speciality_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/name_layout" >
<EditText
android:id="#+id/speciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business speciality" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/address_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/speciality_layout" >
<EditText
android:id="#+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Address" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/name_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/address_layout" >
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/email_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/phone_layout" >
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/timings_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#+id/email_layout" >
<EditText
android:id="#+id/timings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Timings" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_below="#+id/timings_layout"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
android:text="Submit.." />
</RelativeLayout>
</ScrollView>
You can always use LinearLayout in these situations and its easier to manage but
if you don't want to change, this is your fixed layout :
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp" >
<Button
android:id="#+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:text="Close" />
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add a missing Business"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:textColor="#21759b"
android:layout_below="#id/btnClose"
android:layout_centerHorizontal="true"/>
<Spinner
android:id="#+id/spinnerContactType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:minWidth="250dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_below="#id/title"
android:entries="#array/contactType" />
<android.support.design.widget.TextInputLayout
android:id="#+id/name_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/spinnerContactType" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Name" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/speciality_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/name_layout" >
<EditText
android:id="#+id/speciality"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business speciality" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/address_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/speciality_layout" >
<EditText
android:id="#+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Address" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/address_layout" >
<EditText
android:id="#+id/phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Phone" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/email_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/phone_layout" >
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Email" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/timings_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:layout_marginTop="4dp"
app:hintTextAppearance="#style/TextLabel"
android:layout_below="#id/email_layout" >
<EditText
android:id="#+id/timings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLength="65"
android:hint="Business Timings" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:layout_below="#+id/timings_layout"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:background="#21759b"
android:textColor="#FFFFFF"
android:layout_centerHorizontal="true"
android:text="Submit.." />
</RelativeLayout>
first problem with your code was in your case everywhere you used android:layout_below you should use #id/view_id because you had defined that view before and not #+id/view_id
the second problem was you added android:layout_below="#id/phone_layout" and you didn't define phone_layout you had only a view id of name_phone
hope this helps.
I quick review shows that the TextInputLayout with id email_layout uses a layout_below with an unused id of phone_layout.
Perhaps you meant it to reference name_phone. Doing so (or alternately changing the name_phone id) appears to remove the overlapping elements.
Also, I believe the use of #+id/... is only used for the first reference so subsequent references are typically #id/...
in your relative layout use
android:layout_height="wrap_content"
and set proper value for android:layout_marginTopOne more thing you are usin android:layout_below="#+id/phone_layout"but you haven't defined phone_layout
Make it easier for yourself and use LinearLayout instead on a vertical orientation.
I guess you want your email_layout to be below phone_layout, but look - you don't have the layout with id phone_layout - instead of it you have name_phone id. So all you need is to change name_phone id to phone_layout. Good luck :)