layout not going all the way to the bottom - android

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

Related

Android ViewFlipper pushes second layout up

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"

Tried everything but relative layout click is not working at all

This is my layout where I want select_back relative layout to have click listener. But It's not working at all. I could not figure out the issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<RelativeLayout
android:id="#+id/select_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableStart="#drawable/left_arrow"
android:drawablePadding="10dp"
android:focusable="false"
android:fontFamily="sans-serif"
android:text="#string/village_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="normal">
</androidx.appcompat.widget.AppCompatTextView>
</RelativeLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:fillViewport="false">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:paddingBottom="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="#drawable/village_logo" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif"
android:text="#string/village_title"
android:textColor="#color/title_colr"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:backgroundTint="#color/edittext_tint"
android:focusable="true"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_state"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_district"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_block"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:hint="#string/select_village"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/speech"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingBottom="5dp"
android:src="#drawable/mic" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#drawable/button_background"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:padding="10dp"
android:text="Next"
android:textColor="#color/white"
android:textSize="17sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/already_account"
android:textColor="#color/textview_black"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/login_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
This is my Onclicklistener
private RelativeLayout select_back;
select_back = findViewById(R.id.select_back);
select_back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(RegisterActivity.this,
LanuageActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
}
});
I am trying to figure out what is wrong with it but not getting any clue. Could you please help me in figuring out the issue? this is my whole layout part.
Your scrollview overlap the relativelayout so you cannot get click event, just change the sequence and it will works.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:fillViewport="false">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:orientation="vertical"
android:paddingBottom="20dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:src="#drawable/village_logo" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:fontFamily="sans-serif"
android:text="#string/village_title"
android:textColor="#color/title_colr"
android:textSize="20sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:backgroundTint="#color/edittext_tint"
android:focusable="true"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_state"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/district"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_district"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/block"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:gravity="start"
android:hint="#string/select_block"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/village"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/edittext_tint"
android:fontFamily="sans-serif"
android:hint="#string/select_village"
android:inputType="text"
android:padding="20dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/textview_black"
android:textColorHint="#color/textview_black"
android:textCursorDrawable="#null"
android:textSize="14sp"
android:textStyle="normal">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/speech"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="20dp"
android:adjustViewBounds="true"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
android:paddingBottom="5dp"
android:src="#drawable/mic" />
</RelativeLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="#drawable/button_background"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:padding="10dp"
android:text="Next"
android:textColor="#color/white"
android:textSize="17sp"
android:textStyle="normal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/already_account"
android:textColor="#color/textview_black"
android:textSize="14sp"
android:textStyle="normal" />
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:clickable="true"
android:focusable="true"
android:fontFamily="sans-serif"
android:foreground="?attr/selectableItemBackground"
android:gravity="bottom"
android:text="#string/login_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/select_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableStart="#drawable/left_arrow"
android:drawablePadding="10dp"
android:focusable="false"
android:fontFamily="sans-serif"
android:text="#string/village_text"
android:textColor="#color/colorPrimaryDark"
android:textSize="15sp"
android:textStyle="normal">
</androidx.appcompat.widget.AppCompatTextView>
</RelativeLayout>
Thats not a good thing to assign setOnClickListener into a Parent class in xml, but if you want to make it work you need to declare the private RelativeLayout select_back; as global place it on the top of protected void onCreate(Bundle savedInstanceState)
So I came to know that my scroll view layout was overlapping my Relative Layout. I put this Relative Layout inside Scrollview and now it's working like a charm.

editext not getting focus constraint layout

I have added xml for my layout edit text is not getting focus, only selects first one then cannot selects another edittext
I am afraid that somehow focus is not getting or is messed up but could not resolve it anyway.
maybe constraintlayout is culprit but no idea.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar_layout" />
<ScrollView
android:id="#+id/svScroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/toolbar"
app:layout_constraintBottom_toTopOf="#+id/btUpdate"
>
<android.support.constraint.ConstraintLayout
android:id="#+id/constraint_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/black"
>
<EditText
android:id="#+id/etEmailid"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#drawable/profile_background"
android:hint="#string/email_txt"
android:padding="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:inputType="text" />
<EditText
android:id="#+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/First_name"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etEmailid"
/>
<EditText
android:id="#+id/etLastName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/last_name"
android:inputType="textCapWords"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etFirstName" />
<TextView
android:id="#+id/dob"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:drawablePadding="10dp"
android:drawableEnd="#mipmap/mdate"
android:gravity="center_vertical"
android:padding="10dp"
android:hint="#string/dob"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toStartOf="#+id/genderSpinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etLastName" />
<Spinner
android:id="#+id/genderSpinner"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:background="#drawable/profile_background"
android:entries="#array/gender"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="#+id/dob"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/dob"
app:layout_constraintTop_toTopOf="#+id/dob"/>
<EditText
android:id="#+id/etMobileno"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/mobile_txt"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/genderSpinner" />
<EditText
android:id="#+id/etAddress"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/address"
android:inputType="textCapWords"
android:textColorHint="#color/white"
android:textColor="#color/white"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etMobileno" />
<EditText
android:id="#+id/etCity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/S_city"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="textCapWords"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etAddress" />
<EditText
android:id="#+id/etPincode"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:background="#drawable/profile_background"
android:padding="10dp"
android:hint="#string/pincode"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="16sp"
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etCity" />
<TextView
android:id="#+id/tvMandatory"
android:layout_width="match_parent"
android:layout_height="12dp"
android:layout_marginTop="10dp"
android:text="#string/mandatory"
android:textColor="#color/white"
android:textSize="10sp"
android:gravity="right"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/etPincode" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/ivProfile"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginTop="10dp"
android:src="#drawable/prof_img"
app:civ_border_color="#000"
app:civ_border_width="0.5dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvMandatory" />
<TextView
android:id="#+id/tvChoosePhoto"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:background="#drawable/prof_cam"
android:gravity="center|left"
android:paddingLeft="#dimen/plus_15dp"
android:text="CHOOSE YOUR PHOTO"
android:textColor="#color/black"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="#+id/ivProfile"
app:layout_constraintLeft_toRightOf="#+id/ivProfile"
app:layout_constraintTop_toTopOf="#+id/ivProfile" />
<TextView
android:id="#+id/tvClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:gravity="center|left"
android:text="#string/clear"
android:textColor="#color/white"
app:layout_constraintBottom_toBottomOf="#+id/tvChoosePhoto"
app:layout_constraintLeft_toRightOf="#+id/tvChoosePhoto"
app:layout_constraintTop_toTopOf="#+id/tvChoosePhoto"
tools:ignore="MissingConstraints" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
<Button
android:id="#+id/btUpdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/btn_update"
android:text="UPDATE"
android:layout_marginBottom="10dp"
android:textColor="#color/white"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
app:layout_constraintBottom_toBottomOf="parent"
/>
</android.support.constraint.ConstraintLayout>
This shows that I am using scrollview inside constraintlayout which has multiple edit texts and cannot focus second or any of other elements
You can use android:imeOptions="actionNext" to get focus on next EditText item in layout. I have used EditText( or AppCompatEditText) within ConstrainLayout in Scrollview, it working fine.

Upper half the characters entered in EditText field are not visible

In Android Project, upper half of the characters entered in the EditText field are not visible. I tried reducing the fonts from 25sp to 18sp, more part of the letters visible but problem still persists. Reducing font size less than that looks odd in the app. I tried on Margins and padding too, but no result. Please help.
Part of the Layout file :-
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ScrollView01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.constraint.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/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4ab4b2"
tools:layout_editor_absoluteY="81dp">
<TableLayout
android:id="#+id/tableLayout2"
android:layout_width="351dp"
android:layout_height="427dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="#+id/lableDenom"
android:layout_width="60dp"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:text="Denom"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<TextView
android:id="#+id/lableQty"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:paddingLeft="10dp"
android:text="Qty"
android:textAllCaps="false"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<TextView
android:id="#+id/lableValue"
android:layout_width="150dp"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:text="Value"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="#+id/lable2000"
android:layout_width="60dp"
android:layout_height="35dp"
android:background="#color/Rs_2000"
android:paddingLeft="5dp"
android:text="2000"
android:textColor="#android:color/background_light"
android:textSize="25dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<EditText
android:id="#+id/qty2000"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_gravity="bottom"
android:ems="10"
android:inputType="number"
android:maxLength="4"
android:textColor="?attr/colorBackgroundFloating"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result2000"
android:layout_width="150dp"
android:layout_height="35dp"
android:background="#color/Rs_2000"
android:textColor="#android:color/background_light"
android:textSize="25dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
</TableRow> ... ...
Try this :-
<?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:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<android.support.constraint.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/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4ab4b2"
tools:layout_editor_absoluteY="81dp">
<TableLayout
android:id="#+id/tableLayout2"
android:layout_width="351dp"
android:layout_height="427dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="#+id/lableDenom"
android:layout_width="60dp"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:text="Denom"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<TextView
android:id="#+id/lableQty"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:paddingLeft="10dp"
android:text="Qty"
android:textAllCaps="false"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<TextView
android:id="#+id/lableValue"
android:layout_width="150dp"
android:layout_height="35dp"
android:background="#color/colorPrimaryDark"
android:text="Value"
android:textColor="#android:color/background_light"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="#+id/lable2000"
android:layout_width="60dp"
android:layout_height="35dp"
android:gravity="center"
android:padding="4dp"
android:background="#color/Rs_2000"
android:text="2000"
android:textColor="#android:color/background_light"
android:textSize="22sp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
<EditText
android:id="#+id/qty2000"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_gravity="bottom"
android:ems="10"
android:inputType="number"
android:maxLength="4"
android:textColor="?attr/colorBackgroundFloating"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/result2000"
android:layout_width="150dp"
android:layout_height="35dp"
android:background="#color/Rs_2000"
android:textColor="#android:color/background_light"
android:textSize="25dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp" />
</TableRow>
</TableLayout>
</android.support.constraint.ConstraintLayout>
increase your edittext height according to your code UI as you want and textsize 25sp to 22sp, textPadding 5dp to 4dp.
I got an simple solution for the above problem by googling with different question How to remove the underbar in EditText field.
By adding the following code to EditText, the problem is solved. Now I can keep layout_height at 35dp and textSize at 25sp.
android:background="#00000000"

Android RelativeLayout displaying jumbled up

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 :)

Categories

Resources