How to set some views into TextInputLayout on Android - android

In my application i want show views into TextInputLayout.
I want show EditText, TextView (for show countDownTimer) and View (for show line)!
Such as Below Image :
I write below codes, but i can show just EditText and i can't show any other views, such as TextView and View!
My XML codes :
<android.support.design.widget.TextInputLayout
android:id="#+id/signInFrag_phoneInpLay"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginBottom="8dp"
app:boxStrokeColor="#color/colorAccent"
app:boxStrokeWidth="1dp">
<EditText
android:id="#+id/edtLogin1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:drawableEnd="#drawable/ic_phone"
android:drawableRight="#drawable/ic_phone"
android:gravity="right|center_vertical"
android:hint="Phone Number"
android:inputType="phone"
android:maxLength="11"
android:maxLines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColorHint="#c0c0c0"
android:textSize="12sp" />
</android.support.design.widget.TextInputLayout>
How can i change my code for show such as above image?

You can set view as overlap on textInputLayout by constraintLayout. May be it has risk to overlap editText`s text with count text or vertical view. But i found in your text view has text limit. so For your reason it is not possible overlap the count text view.
Code **
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Page"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/input_layout"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:boxStrokeColor="#color/colorAccent"
app:boxStrokeWidth="1dp"
app:hintEnabled="true"
app:layout_constraintTop_toBottomOf="#+id/title">
<EditText
android:id="#+id/edtLogin1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:drawableStart="#drawable/ic_action_profile"
android:gravity="left|center_vertical"
android:hint="Phone Number"
android:inputType="phone"
android:maxLength="11"
android:maxLines="1"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColorHint="#c0c0c0"
android:textSize="12sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/text_view_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="22sec"
app:layout_constraintBottom_toBottomOf="#+id/input_layout"
app:layout_constraintEnd_toEndOf="#+id/input_layout"
app:layout_constraintTop_toTopOf="#+id/input_layout" />
<View
android:id="#+id/view"
android:layout_width="1dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="#+id/input_layout"
app:layout_constraintEnd_toStartOf="#+id/text_view_time"
app:layout_constraintTop_toTopOf="#+id/input_layout" />
</androidx.constraintlayout.widget.ConstraintLayout>

Related

Button not visible during scroll view

I have a scroll view wrapping a LinearLayout , i have a button at the end of the layout , the entire layout is visible and scrollable but the button at the end is not visible , it becomes visible if i put it at first or make space for the button without the scroll view.
code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/container1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20sp"
android:orientation="horizontal"
android:padding="25sp"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="25sp"
android:layout_weight="1"
android:fontFamily="#font/roboto_bold"
android:text="TEST"
android:textSize="20sp" />
<ImageView
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="25sp"
android:contentDescription="close"
android:src="#drawable/test" />
</LinearLayout>
<ScrollView
android:id="#+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/container1">
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="25sp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="TEXT"
android:importantForAutofill="no"
android:inputType="text"
android:padding="40sp"
android:textSize="22sp"
android:textStyle="bold" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/blue"
android:text="#string/submit"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
I have tried changing to androidx.appcompat.widget.AppCompatButton , use image button but still no avail,
I tried to give hard coded height and width still it's not visible.
After some playing around i just found out that my last child is not visible be it button, text or any other
Any help is appreciated
You just have to add this line of code inside your Button Widget.
android:layout_marginBottom="50dp"
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/blue"
android:text="#string/submit"
android:textColor="#color/white"
android:layout_marginBottom="50dp" // Add this line
/>
This will solve your problem. Thank you.
You just need to change Scrollview code with
<ScrollView
android:id="#+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/container1">

trying to align a view vertically to the edit text inside the inputlayout [see image] the helper text shifts the alignment

just look how the OTP button seems to not be aligned properly. how do I fix that?
I'm using material UI's outlined textfeild which also has a helper text. That adds to the height of the input layout. hence, this issue. I want the OTP button to be aligned perfectly besides the text field. is there a way to do that other than making the helper text into a textview? I also don't want to use margin on the button to align it because that can cause unexpected changes in different screen sizes. Here's the code -
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/login_card_spacing"
app:cardBackgroundColor="#eeeeee"
app:cardCornerRadius="#dimen/login_card_spacing">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/sign_up_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/login_card_spacing"
android:text="SIGN UP"
android:textSize="#dimen/huge_text_size"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/user_name_edit_text"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/login_card_spacing"
android:hint="User Name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/sign_up_label">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/user_password_edit_text"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/login_card_spacing"
android:hint="Set New User Password"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/user_name_edit_text">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/user_phone_number_edit_text"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/login_card_spacing"
android:hint="Phone Number"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/user_password_edit_text">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/user_otp_edit_text"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/login_card_spacing"
android:layout_marginEnd="#dimen/login_card_spacing"
android:hint="OTP Generated"
app:helperText="Check Message Box For The Entered Phone Number"
app:layout_constraintLeft_toLeftOf="#id/user_name_edit_text"
app:layout_constraintRight_toLeftOf="#id/otp_generator"
app:layout_constraintTop_toBottomOf="#id/user_phone_number_edit_text">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/otp_generator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="otp"
app:layout_constraintBottom_toBottomOf="#id/user_otp_edit_text"
app:layout_constraintRight_toRightOf="#id/user_name_edit_text"
app:layout_constraintTop_toTopOf="#id/user_otp_edit_text" />
<Button
android:id="#+id/cancel_login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginVertical="#dimen/login_card_spacing"
android:layout_marginEnd="#dimen/login_card_spacing"
android:text="cancel"
style="?attr/materialButtonOutlinedStyle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="#id/user_name_edit_text"
app:layout_constraintRight_toLeftOf="#id/register_login"
app:layout_constraintTop_toBottomOf="#id/user_otp_edit_text" />
<Button
android:id="#+id/register_login"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/login_card_spacing"
android:text="register"
app:layout_constraintBottom_toBottomOf="#id/cancel_login"
app:layout_constraintLeft_toRightOf="#id/cancel_login"
app:layout_constraintRight_toRightOf="#id/user_name_edit_text"
app:layout_constraintTop_toTopOf="#id/cancel_login" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

How to constrain a sibling view to same height as that of TextInputEditText of an TextInputLayout

I want to show the label "Km" with a white background with the same height as that of the edit text field.
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayoutInputDist"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="wrap_content"
android:layout_height="42dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/inputDist"
android:layout_width="80dp"
android:layout_height="match_parent"
android:background="#drawable/bg_left_corner_shape"
android:backgroundTint="#android:color/white"
android:fontFamily="#font/roboto_regular"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxEms="4"
android:padding="4dp"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/label_km"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:background="#drawable/bg_right_corner_shape"
android:backgroundTint="#android:color/white"
android:fontFamily="#font/roboto_regular"
android:gravity="center_vertical"
android:text="#string/km"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/textInputLayoutInputDist"
app:layout_constraintTop_toTopOf="#+id/textInputLayoutInputDist" />
</androidx.constraintlayout.widget.ConstraintLayout>
But the TextInputLayout is taking some more height that the edit text field, I cant align the edit text and the "Km" label vertically the same levels.
As I understand your question check below answer
Give kmLable top and bottom constraint to edit text. Here I give fix width for a temporary purpose (change according to your requirement).
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayoutInputDist"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/inputDist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dividerColor"
android:fontFamily="#font/roboto_bold"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxEms="4"
android:padding="4dp"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="#+id/label_km"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:background="#color/dividerColor"
android:fontFamily="#font/roboto_medium"
android:gravity="center_vertical"
android:text="km"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="#+id/textInputLayoutInputDist"
app:layout_constraintStart_toEndOf="#+id/textInputLayoutInputDist"
app:layout_constraintTop_toTopOf="#+id/textInputLayoutInputDist" />
</androidx.constraintlayout.widget.ConstraintLayout>
try
setHintEnabled(false)
in your xml like this:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textInputLayoutInputDist"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/inputDist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/dividerColor"
android:fontFamily="#font/roboto_bold"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxEms="4"
android:padding="4dp"
android:textColor="#color/colorPrimaryDark"
android:textSize="14sp" />
</com.google.android.material.textfield.TextInputLayout>

Make soft keyboard scroll view rather than resize it

I am trying to emulate an iOS-like keyboard for my Android app. Simply put, the contents of my activity should scroll behind the keyboard without resizing the spacing (which is what android:windowSoftInputMode="stateHidden|adjustResize" does).
I can achieve a close scroll behavior by making my parent layout a ScrollView (as suggested in Make soft keyboard behave like IOS in Android), but doing so also scrolls my custom action bar (which is an included android.support.v7.widget.Toolbar). Either I am not implementing a custom action bar correctly (so it is always at the top of the screen, ignoring scrolling), or there is some trick to get the soft keyboard to only scroll a resize (and scroll) a specific element to make room for itself.
Hopefully this simple picture illustrates what I'm trying to achieve. In the screen on the right, the actionbar is left untouched and the main content spacin remains the same and the view is scrollable.
This is my custom actionbar layout that I include in my activity.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#color/primaryRed"
android:elevation="4dp"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="-7dp"
android:contentDescription="#string/back"
android:scaleType="centerInside"
android:src="#drawable/ic_up_unpadded" />
<TextView
android:id="#+id/hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="20dp"
android:text="#string/back"
android:textColor="#android:color/white"
android:textSize="20sp" />
</RelativeLayout>
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/theGlassFiles"
android:textAllCaps="true"
android:textColor="#android:color/white"
android:textSize="22sp" />
</android.support.v7.widget.Toolbar>
The current view experiment layout is below. I've tried many things, none of which work. The one below is my latest test, which also does not achieve what I am try to get to.
<?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:fillViewport="true"
android:fitsSystemWindows="true"
tools:context="JoinActivity">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<include
layout="#layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/message"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_marginTop="76dp"
android:gravity="center"
android:lineSpacingExtra="8sp"
android:text="#string/joinMessage"
android:textColor="#color/primaryBlue"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/form"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/message"
app:layout_constraintVertical_bias="0.176">
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/firstNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/middleName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/middleNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/lastNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/town"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/townHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/passwordHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/confirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/confirmPasswordHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<Button
android:id="#+id/joinButton"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="25dp"
android:background="#color/primaryRed"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="22sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
EDIT
Swapping around the parent/children layouts, I achieve something really close to what I'm aiming for. The actionbar always is on top, and the keyboard only resizes the scroll view. However, when I scroll I cannot scroll above the first EditText element. Using the picture, I can only scroll up to the first input, and cannot continue to scroll up and see the green icon. Using my actual XML layout, I cannot scroll to see the TextView component. Here is the updated layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="JoinActivity">
<include
layout="#layout/actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="#id/actionbar">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:id="#+id/message"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:gravity="center"
android:lineSpacingExtra="8sp"
android:text="#string/joinMessage"
android:textColor="#color/primaryBlue"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/form"
android:layout_width="362dp"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/message"
app:layout_constraintVertical_bias="0.464">
<EditText
android:id="#+id/firstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/firstNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/middleName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/middleNameHint"
android:imeOptions="actionDone"
android:inputType="textPersonName" />
<EditText
android:id="#+id/lastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/lastNameHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/town"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/townHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/passwordHint"
android:inputType="textPersonName" />
<EditText
android:id="#+id/confirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:hint="#string/confirmPasswordHint"
android:inputType="textPersonName" />
<Button
android:id="#+id/joinButton"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_marginTop="25dp"
android:background="#color/primaryRed"
android:text="#string/join"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="22sp" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
</RelativeLayout>

Focus on last edittext in Custom Dialog doesn't work

In my App I'm using a Custum Dialog (android.app.Dialog) with three Edit Texts in it. I'm able to set the next focus from the first to the second EditText when I press the next Button on the SoftKeyboard, but it doesen't work to set the focus on the third EditText. I already tried to set nextFocusForward or nextFocusDown and so on but it still doesn't work.
Here is the XML Layout from my Custom Dialog:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/addcard_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/dialog_addcard_info" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="#+id/addcard_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:hint="#string/name"
android:inputType="text"
android:lines="1"
android:maxLines="1"
android:scrollHorizontally="true" />
<EditText
android:id="#+id/addcard_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/number"
android:inputType="number"
android:maxLength="16"
android:scrollHorizontally="true"/>
<EditText
android:id="#+id/addcard_pin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/pin"
android:inputType="numberPassword"
android:maxLength="4"
android:textSize="14sp"
android:scrollHorizontally="true"/>
</LinearLayout>
<TextView
android:id="#+id/addcard_errormessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="#string/error"
android:textColor="#ff0000"
android:textStyle="bold"
android:visibility="gone" />
<Button
android:id="#+id/addcard_verify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="#string/verify" />
</LinearLayout>
Does anyone have an idea why i'm not able to set the focus on the third EditText?
Thanks in advance.
try this one in your code :)
<EditText
android:id="#+id/addcard_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="#string/number"
android:inputType="number"
android:maxLength="16"
android:imeOptions="actionNext" // try this one
android:nextFocusDown="#+id/addcard_errormessage" // and add this one
android:scrollHorizontally="true"/>

Categories

Resources