I have a ScrollView with some widgets in it, amongst them an EditText. When I write a couple of lines in the EditText (id:message), I can't scroll the ScrollView all the way up to the top, it is stuck until I close the soft keyboard. After that, if I go into the EditText again and write another couple of lines, this doesn't happen anymore. This only happens on Android 4.x, not on 2.3.
How can I prevent my ScrollView from getting stuck?
Here's my layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingTop="#dimen/activity_vertical_margin" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<EditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/ihr_name"
android:imeOptions="flagNoExtractUi"
android:inputType="textPersonName"
android:singleLine="true" >
</EditText>
<EditText
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:hint="#string/ihre_email"
android:imeOptions="flagNoExtractUi"
android:inputType="textEmailAddress"
android:singleLine="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/startDate"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/starterror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/endDate"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/enderror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/xy"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/adulterror"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#00000000" />
</RelativeLayout>
<asco.asco.spinnerbuttonlib.spinnerbutton.StaticSpinnerbutton
android:id="#+id/tre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="24dp"
android:text="Message: "
android:textAppearance="#style/StandardTextBold"
android:textColor="#color/myorange" />
<EditText
android:id="#+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:hint="#string/ihre_nachricht"
android:inputType="textNoSuggestions|textMultiLine"
android:text="#string/contact_message" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/pflichtfelder"
android:textAppearance="#style/SmallText" />
<Button
android:id="#+id/send"
style="#style/ButtonTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Senden" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/contact_datenschutz"
android:textAppearance="#style/SmallText" />
</LinearLayout>
</ScrollView>
Here's a screenshot of the stuck layout (not too interesting probably):
Your input options are set to pan (keep the view we are inputting visible)
add android:windowSoftInputMode="adjustResize" to your activity declaration in the manifest
Related
Comparison of code, Final result and Layout Validation
I'm trying to generate a Button on the bottom of the Screen, First I use a linear layout for the other elements of the data recollecting program, it uses two other layouts to generate an auto-sizing list, everything is working well with exception of the last button that appears in the Layout Validation but when I run it, it disappears.
enter code here
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="10">
<LinearLayout
android:id="#+id/ly1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:orientation="vertical">
<TextView
android:id="#+id/txN1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/nombre"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/txN2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:background="#color/divider"
android:inputType="text"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txf1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/fecha"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<TextView
android:id="#+id/txf2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/divider"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<Button
android:id="#+id/btf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_2"
android:text="#string/deffecha"
android:theme="#style/Button1" />
<TextView
android:id="#+id/txT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margeny_1"
android:text="#string/telefono"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="Phone"
android:background="#color/divider"
android:inputType="phone"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/email"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/divider"
android:inputType="textEmailAddress"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
<TextView
android:id="#+id/txDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/descripcion"
android:textColor="#color/primary_text"
android:textSize="#dimen/texto_2" />
<EditText
android:id="#+id/edDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:background="#color/divider"
android:inputType="text"
android:textColor="#color/secondary_text"
android:textSize="#dimen/textos_1" />
</LinearLayout>
</LinearLayout>
<Button
android:id="#+id/btSig"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:baselineAligned="false"
android:text="Siguiente"
android:theme="#style/Button1"
app:layout_constraintBottom_toBottomOf="#+id/linearLayout"
/>
</LinearLayout>
I don't know why and how You want to auto-resize content but I make something like this:
<?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">
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#+id/btSig"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/txN1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="nombre" />
<EditText
android:id="#+id/txN2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="username"
android:inputType="text" />
<TextView
android:id="#+id/txf1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="fecha" />
<TextView
android:id="#+id/txf2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:id="#+id/btf1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="deffecha" />
<TextView
android:id="#+id/txT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="telefono" />
<EditText
android:id="#+id/edT1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="Phone"
android:inputType="phone" />
<TextView
android:id="#+id/txE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="email" />
<EditText
android:id="#+id/edE1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />
<TextView
android:id="#+id/txDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edDC1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:inputType="text" />
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/btSig"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:text="Siguiente"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
(Of course, I change strings and dimension values)
It looks like that:
One button is always on the bottom of the screen and the rest in scroll view.
I have this layout of fragment:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="fragments.FrgLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<ImageView
android:id="#+id/logoFragmentLogin"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:src="#drawable/logo_erp24h"
android:transitionName="logoTransition" />
<LinearLayout
android:id="#+id/loginLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/proxima_nova"
android:gravity="center"
android:text="#string/bemVindo"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/proxima_nova"
android:gravity="center"
android:text="#string/instrucaoLogin"
android:textColor="#color/gray"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/linearLayoutTwo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:paddingTop="20dp">
<EditText
android:id="#+id/usernameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/proxima_nova"
android:hint="#string/usuario"
android:textIsSelectable="true"
android:textColor="#color/gray"
android:textColorHint="#color/light_gray"
android:theme="#style/loginFields" />
<android.support.design.widget.TextInputLayout
android:id="#+id/etPasswordLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintEnabled="false"
app:passwordToggleEnabled="true"
app:passwordToggleTint="#color/gray">
<android.support.design.widget.TextInputEditText
android:id="#+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/proxima_nova"
android:hint="#string/senha"
android:inputType="textPassword"
android:textColor="#color/gray"
android:textColorHint="#color/light_gray"
android:theme="#style/loginFields" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/loginEnterButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/blue_background"
android:clickable="true"
android:padding="6dp">
<ImageView
android:id="#+id/loginEnterImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_right_arrow" />
<ProgressBar
android:id="#+id/loginEnterProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateTint="#color/white"
android:visibility="invisible" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="#font/proxima_nova"
android:text="#string/entrar"
android:textColor="#color/primary"
android:textSize="20sp"
android:textStyle="bold|italic" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
When a digit a text in username and password fields, the cursor accompanies the text, but nothing appear. This fragment is load inside a Acitivty on a Frame Layout. This bug happens only on Android Lollipop device, on emulator and real smartphone;
I can select text and copy, cut, paste, but continues invisible
Please help me !!
Methods used on Fragment class with setVisibility not working
I am facing the issue ,when the soft keyboard is appeared the frame layout in top of the activity is pushed up .The Frame Layout is placed inside the Linear Layout and below the scrollview is placed inside the scrollview multiple edittext are placed . I have tried the answers posted in the stack overflow but still my problem is not solved.
I am buliding the app in target sdk version 25 and mimimum version 16.
I applied `below method to the activity in AndroidManifestFile.
<activity android:name=".Activities.ScamLookUpActivity"
android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout|"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>`
I don't know how to solve this error and tell the reason the why the given method is not appllied to my activity.
This is my xml layout file...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_scam_look_up"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#eee"
tools:context="com.zcodia.scamlookup.Activities.ScamLookUpActivity">
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<View
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_height="?android:attr/actionBarSize"
android:background="#mipmap/bg_splash_cut">
</View>
<View
android:layout_width="match_parent"
android:layout_height="25dp"
android:alpha="1"
android:background="#A82A37" />
<TextView
android:id="#+id/left_buton"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="30dp"
android:text="#string/menu"
android:textSize="30dp"
android:gravity="center"
android:textColor="#FFF"/>
<com.zcodia.scamlookup.Utils.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Scam lookup"
android:layout_marginTop="29dp"
android:layout_marginLeft="60dp"
android:textSize="20dp"
android:textColor="#FFF"
android:gravity="center"/>
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#f9f9f9"
android:focusableInTouchMode="true"
android:paddingBottom="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:background="#drawable/text_input2"
>
<com.zcodia.scamlookup.Utils.CustomTextView
android:text="Search Scam Database"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:id="#+id/textView4"
android:textSize="20dp"
android:textColor="#000"
android:layout_below="#+id/linearLayout"
android:typeface="sans"
/>
<com.zcodia.scamlookup.Utils.CustomTextView
android:text="Contact Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_marginLeft="10dp"
android:id="#+id/details_id"
android:textColor="#D32F2F"
android:typeface="sans"
android:textSize="15dp"
android:layout_marginTop="10dp"/>
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="60dp"
android:id="#+id/recyclerView"
></android.support.v7.widget.RecyclerView>
</LinearLayout>
<com.zcodia.scamlookup.Utils.CustomTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Category"
android:id="#+id/textView5"
android:layout_below="#+id/linearLayout2"
android:layout_marginTop="10dp"
android:layout_marginLeft="15dp"
android:textColor="#D32F2F"
android:textSize="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical"
android:paddingBottom="20dp"
android:id="#+id/relative_spinner"
android:focusableInTouchMode="true">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/textinput"
android:layout_marginRight="10dp">
<Spinner
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:id="#+id/categorySpinner"
android:text="#string/inheritance"
android:prompt="#string/inheritance"
android:paddingLeft="0dp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="#drawable/textinput"
android:layout_marginRight="10dp">
<Spinner
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="1dp"
android:id="#+id/categorySpinner2"
android:text="#string/inheritance"
android:prompt="#string/inheritance"
android:paddingLeft="0dp"
/>
</RelativeLayout>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="phone"
android:id="#+id/phoneNumber_editText"
android:hint="#string/phonenumber"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:layout_marginTop="0dp"
android:id="#+id/yourLocation"
android:hint="Location"
android:textColorHint="#757575"
style="#style/CustomFontStyle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="330dp"
android:text=""
android:id="#+id/scammer_location_font"
android:textColor="#3eb3a0"
android:textSize="25dp"
android:layout_marginTop="10dp"/>
</RelativeLayout>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="textPersonName"
android:hint="#string/scammer_location"
android:id="#+id/scammerLocation_editText"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
/>
<com.zcodia.scamlookup.Utils.CustomEditText
android:inputType="textPersonName"
android:hint="#string/keyWord"
android:id="#+id/keyword_edittext"
android:background="#drawable/textinput"
android:typeface="sans"
style="#style/CustomFontStyle"
android:layout_marginTop="20dp"
/>
</LinearLayout>
<com.wefika.flowlayout.FlowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/clip_flow_layout"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
</com.wefika.flowlayout.FlowLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<com.zcodia.scamlookup.Utils.CustomButton
android:text="Search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/search_id"
android:background="#mipmap/bg_splash_cut"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
</LinearLayout>
</ScrollView>
The below image is my activity.
when the edittext is pressed the top frame layout is pushed up.
I think you should try "statehidden" and "adjustPan" together.
<activity android:windowSoftInputMode="adjustPan|stateHidden">
Try this answer,
<activity android:windowSoftInputMode="adjustPan"> </activity>
apply this attribute to your Scroll view:android:fitsSystemWindows="true" and Follow this
link
So I have surrounded RelativeLayout with ScrollView but when I run it in the Android emulator, it is still not scrolling. Did I accidentally messed up some code? Because it just stopped scrolling.
Here is the xml:
<?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="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:id="#+id/new_meal_form_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/meal_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:text="#string/meal_label"
android:textSize="20sp"/>
<EditText
android:id="#+id/meal_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_label"
android:hint="Event Title"
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="#+id/meal_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_name"
android:hint="Location(eg: CSC Room232)* "
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="#+id/meal_event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_location"
android:gravity="top"
android:hint="Description of the event. What kind of food. Any additional info... \n"
android:inputType="textMultiLine|textCapSentences"/>
<TextView
android:id="#+id/textViewRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/meal_event"
android:text="Rating: "/>
<Spinner
android:id="#+id/rating_spinner"
android:layout_width="71dp"
android:layout_height="47dp"
android:layout_alignTop="#+id/textViewRequired"
android:layout_toRightOf="#+id/textViewRating"/>
<TextView
android:id="#+id/textViewRequired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textViewRating"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:text="*Required"
android:textColor="#ffff4b48"
android:textSize="15sp"/>
<com.parse.ParseImageView
android:id="#+id/meal_preview_image"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_below="#+id/rating_spinner"
android:layout_centerHorizontal="true"/>
<ImageButton
android:id="#+id/photo_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_photo"
android:layout_below="#+id/meal_preview_image"
/>
<Button
android:id="#+id/save_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/photo_button"
android:layout_toLeftOf="#+id/cancel_button"
android:background="#ffff001f"
android:text="#string/save_button_text"/>
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/photo_button"
android:text="#string/cancel_button_text"/>
</RelativeLayout>
</ScrollView>
The height of your relative layout should be android:layout_height="wrap_content"
I have created an app in which there is an edittext to take input from user and below it there is an button. When the user click or focus on the edittext to input something the button position is changed by the keyboard and it overlap the edittext. I have tried the solution provided in
this answer. But it doesn't helped me
i have used this
android:windowSoftInputMode="stateVisible|adjustNothing
please someone hep....
Edit:
This is my layout xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#ffffff"
tools:context=".MyAds"
android:id="#+id/TestAd"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
>
<EditText
android:id="#+id/edtLoanAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtLoanAmount"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtLoanAmount"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<EditText
android:id="#+id/edtRateOfInterest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtRateOfInerest"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtRateOfInerest"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="numberDecimal" />
<TextView
android:id="#+id/txtRateOfInerest"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/edtLoanAmount"
android:layout_below="#+id/edtLoanAmount"
android:layout_marginTop="14dp"
android:text="Rate of Inerest"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtLoanAmount"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="16dp"
android:text="Enter Loan Amount"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtLoanTenure"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/edtRateOfInterest"
android:layout_marginTop="16dp"
android:text="Loan Tenure (In Months)"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/edtLoanTenure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtLoanTenure"
android:ems="10"
android:background="#drawable/rounded_edittext_states"
android:inputType="number" />
<TextView
android:id="#+id/txtEMI"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/btnCalculateEmi"
android:layout_marginTop="20dp"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/btnLoanAmorSchedule"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/txtEMI"
android:layout_marginTop="16dp"
android:background="#drawable/rounded_button_states"
android:text="Loan Amortization Schedule" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="125dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="#drawable/initqube" />
<Button
android:id="#+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="#id/edtLoanTenure"
android:background="#drawable/rounded_button_states"
android:text="Calculate EMI" />
<com.google.android.gms.ads.AdView
android:id="#+id/MyAdView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/imageView1"
android:layout_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="xxxxxxxxx" >
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</ScrollView>
my issue has been solved...
<Button
android:id="#+id/btnCalculateEmi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingTop="3dp"
android:layout_marginTop="5dp"
android:layout_below="#id/edtLoanTenure"
android:background="#drawable/rounded_button_states"
android:text="Calculate EMI" />
After removing the
android:layout_centerVertical="true"
from the button property. Everything works like a charm...
Add android:windowSoftInputMode="adjustPan"
in the Android Manifest XML file for your Activity.