Reputation: 73
Problem is as per the title. I have a floating action button at the right-bottom screen corner. When clicking on some editText field, then this button floats nicely to the top of the onscreen keyboard as per screenshot:
Problems start if I have focus set on editText view and then rotate the screen. After that point onwards whenever I click on editText field then the keyboard comes up but the floating button does not, so it gets covered up by the keyboard.
Like this:
After this happens, it does not matter if I move between frames or do some activities. The problem stays and this behaviour appears throughout the app wherever I have some editText fields and a floating button, it won't float with the keyboard. It just gets covered up by the keyboard. Things return to normal only after I have completely closed the app and restarted.
Now I'm still newbie when it comes to Android development, so I'm not sure what more info I could/should provide. I'm using Android Xiaomi P30 pro for testing (if it makes any difference).
android settings
compileSdkVersion 29
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "ee.taltech.mobile.contacts"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
Resource for button and editTxt fields
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".fragments.AddPersonFragment">
<EditText
android:id="@+id/addContactValue_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="First Name"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/addLastName_edit"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:ems="10"
android:hint="Last Name"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/addContactValue_edit" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/add_person_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginBottom="24dp"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_check"
android:tint="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Upvotes: 1
Views: 463