I have the following layout,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/name"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/address_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/address_name"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/address"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/street"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/street"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/city"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/state"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/state"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/postal_code"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/postal_code"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/landmark"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/landmark"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
When I enter data, the soft keyboard hides the fields. I tried setting android:windowSoftInputMode="adjustPan" in manifest with various setting like adjustNothing, adjustResize etc. These settings never worked.
I want to have the fields scrollable, above the soft keyboard. So data can be entered like default edit contact app in Android.
Tried with Android 5.1
Related
I'm playing with TextInputEditText and I'm front face a strange issue. When I edit the content of the first one, let's say the "Nom" field, everything looks good, the keyboard appears and I can see the entered text. Now if I need to enter a text in a text field which is under the keyboard, the Activity pans up so the field is in view, but I can NOT see the text that I'm entering... Please have a look at this video: https://www.digitalblend.fr/android_TextInputEditText_issue.mp4
Moreover please have a look at my actual code :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MessageFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="120dp" />
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_last_name"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/lastname"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="textPersonName"
android:nextFocusDown="#+id/firstname"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<View
android:layout_width="10dp"
android:layout_height="0dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/first_name"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/firstname"
android:layout_width="match_parent"
android:padding="5dp"
android:hint=""
android:maxLines="1"
android:inputType="textPersonName"
app:textInputLayoutFocusedRectEnabled="true"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_mail"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/email"
android:layout_width="match_parent"
android:padding="5dp"
android:hint=""
android:maxLines="1"
android:inputType="textEmailAddress"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_enterprise"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/enterprise"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_code_postal"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/postal_code"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/city"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/city"
android:layout_width="match_parent"
android:padding="5dp"
android:maxLines="1"
android:hint=""
android:inputType="text"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/phone_number_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/black"
android:textStyle="bold"
android:text="#string/required_tel"/>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/phone_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="5dp"
android:paddingHorizontal="15dp"
android:maxLines="1"
android:inputType="text"
android:textColor="#color/black"
android:imeOptions="actionDone"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/btn_buy"
android:layout_width="match_parent"
android:layout_height="50dp"
android:scaleType="fitCenter"
android:background="#drawable/little_red_button"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="20dp"
android:text="#string/send_demand"
android:gravity="center"
android:textColor="#color/white"
android:textSize="14sp"/>
</LinearLayout>
</ScrollView>
In my manifest I used android:windowSoftInputMode="adjustPan">
If someone has an idea ? Thanks in advance.
I'm creating an Activity which user can create a Question and where can create answers, so, from now I have this :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/constraintAnswerTypes"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="#string/respuesta_1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp" />
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:hint="#string/respuesta_2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
And the result is this one :
The problem that I'm having is if the answer that user types is too long he can not see it , so I'm thinking to do something like match_parent on the width so user has more space to write, but then I have this also :
And perhaps create 4 different lines for each answer is kinda ugly...
My initial question is, how do I create the first output to be match_parent like if there's only 2 answers, but then the thing is when I have the four answers, how do I print those EditText?
Edit
For the first option I want something like this, there 2 lines are the TextInputLayout with the EditTexts and the circle on the right is the RadioButton
Please check below code. It will solve your issue for both case, just need to handle visibility for alternate answers. If you face any issue then please let me know in comment section.
Use your own drawables and assets.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 3"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer3_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linear_view_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 4"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer4_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
For Vertical layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/viewBinary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_view_option_1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_1_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 1"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer1_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_3_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option3_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 3"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer3_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_2_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option2_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 2"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer2_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_view_option_4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input_option_4_binary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="1"
app:hintTextAppearance="#style/Widget.Design.TextInputLayout">
<EditText
android:id="#+id/et_option4_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Resposta 4"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/cb_answer4_binary_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" />
</LinearLayout>
</LinearLayout>
Please approve answer if it will work for you. Thanks!
Try this
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true" android:id="#+id/linear_view_option_1_binary">
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_weight = 1
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:hintTextAppearance="#style/TextLabel"
android:id="#+id/txt_input_option_1_binary"
android:layout_marginBottom="8dp">
<EditText android:id="#+id/et_option1_binary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:hint="#string/respuesta_1"/>
</android.support.design.widget.TextInputLayout>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:layout_marginBottom="8dp" android:id="#+id/cb_answer1_binary_option"/>
</LinearLayout>
Basically we are setting layoutweit to be equal 1 on the edit text (or textinput in your case) and the width to 0dp. This way Edittext will consume only the available space, not the whole width
<LinearLayout
android:id="#+id/linear_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="#+id/txt_input"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:hintTextAppearance="#style/TextLabel">
<EditText
android:id="#+id/edt_option"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textCapSentences" />
</android.support.design.widget.TextInputLayout>
<RadioButton
android:id="#+id/rb_answer"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
In my layout i have some edit text and a scroll view.The problem is when I touch the edit text the soft keyboard is open but if i try to scroll down it is not scrolling down fully. Same case happen when i try to scroll up fully.
But if i use android : windowSoftInputMode="adjustresize" i can scroll fully up but my keyboard hide the bottom edit text.I also try to use
android : windowSoftInputMode="adjustspan|adjustresize" but no solution found.
Another problem is that I show some error message when user try to input same text if it is match but when close the soft keyboard the message is not attaching with its right position.
its my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >
<include
android:id="#+id/toolbar"
layout="#layout/toolabar"
android:theme="#style/mycustomtoolbartheme"></include>
<ScrollView
android:id="#+id/scrollView_addproductactivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="true"
>
<LinearLayout
android:id="#+id/activity_add_product"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<Button
android:id="#+id/btn_save_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:background="#drawable/shape1"
android:text="Save"
android:textColor="#fff" />
<Button
android:id="#+id/btn_view_addProductActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:background="#drawable/shape1"
android:text="view"
android:textColor="#fff" />
</RelativeLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitePn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Product Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocompliteBn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Brand Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_MN"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Model Num"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Quantity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Quantity"
android:imeOptions="flagNoExtractUi"
android:inputType="number"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_PPP"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Price per Pice"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitecn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Country "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocomplitecolor_name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Color "
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_ProductSize"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Size"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<AutoCompleteTextView
android:id="#+id/autocompliteDname"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Delleremail"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Email"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_DellerPhn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Phn Num"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Delleradd"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Add"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp">
<EditText
android:id="#+id/edittext_Dellerfax"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="15dp"
android:hint="Dealer Fax"
android:imeOptions="flagNoExtractUi"
android:inputType="phone"
android:textSize="20dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
i add this code to my manifest file but no solution found
<activity
android:name="com.example.oggy.productcatalog.AddProductActivity"
android:windowSoftInputMode="adjustPan"
/>
If you are fine with layout not adjusting
<activity android:name="com.example.oggy.productcatalog.AddProductActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />
I want that my edit button always shows on the bottom of the screen. Below is my code.
<?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:padding="#dimen/dimen_16dp">
<Button
android:id="#+id/button_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#color/colorPrimaryDark"
android:text="#string/edit"
android:textSize="20sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_above="#+id/button_edit">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/name"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_name_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_dob_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/date_of_birth"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/til_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_dob_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:focusable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_gender_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/gender"
android:inputType="date"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_gender"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="clip_vertical"
android:hint="#string/house_no_sector_street_phase_floor_etc"
android:inputType="textCapSentences"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_address_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_pin_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/pin_code"
android:inputType="number"
android:maxLength="6"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/til_pin_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_state_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/state"
android:inputType="textCapWords"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_state_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_contact_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:gravity="center_vertical"
android:hint="#string/mobile_no"
android:inputType="number"
android:maxLength="10"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/til_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/til_contact_view"
android:layout_marginBottom="8dp"
android:background="#drawable/register_layout_background"
android:clickable="false"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<EditText
android:id="#+id/et_email_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:background="#color/transparent_color"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:hint="#string/e_mail"
android:inputType="textEmailAddress"
android:paddingTop="4dp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Problem: The problem is that the button does not display on the bottom instead it shows on the top of the screen and ScrollView is not visible at all. If I change match_parent in android:layout_height="match_parent" of the outer RelativeLayout to some value like 500dp then it works ok but as soon as I change it to match_parent the button goes on the top.
Can anyone help me find where I need to be corrected? Thanks
I had put my FrameLayout inside scrollView. and in the layout of fragment I was trying to use again scrollView, therefore, I was facing the issue. I solved it by removing scrollview of framelayout
I've DialogFragment and three TextInputLayouts. When I click on the first TextInputLayout then the keyboard opens. And it does not disappear when you click on others TextInputLayout.
getDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
or
android:windowSoftInputMode="stateHidden"
don't work.
How to solve a problem?
My .xml code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskDate"
android:layout_width="130dp"
android:layout_below="#+id/tilDialogTaskTitle"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:inputType="none"
android:focusableInTouchMode="false"
android:cursorVisible="false"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/tilDialogTaskTime"
android:layout_width="130dp"
android:layout_alignRight="#+id/tilDialogTaskTitle"
android:layout_below="#+id/tilDialogTaskTitle"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:inputType="none"
android:focusableInTouchMode="false"
android:cursorVisible="false"/>
</android.support.design.widget.TextInputLayout>
<Spinner
android:id="#+id/spDialogTaskPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/tilDialogTaskDate"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="10dp"
/>
</RelativeLayout>
</ScrollView>