Softkeyword overlaps bottom button when displayed in BottomSheetDialogFragment
I want the soft keyboard to show below the bottom button in my BottomSheet when active, basically moving the BottomSheet up. Currently, it sort of does this but it overlaps the button below the EditText view, so the top of the keyboard limits with the bottom of the EditText view that is receiving input.
Here is the bottom_sheet.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:isScrollContainer="false" android:fillViewport="true" > <LinearLayout android:id="@+id/bottom_sheet" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:orientation="vertical" android:padding="16dp" app:behavior_hideable="false" app:behavior_peekHeight="90dp" app:layout_behavior="android.support.design.widget.BottomSheetBehavior"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Recupera tu contraseña" style="@style/BigSectionTitleText" android:textSize="22sp" android:layout_marginBottom="10dp" android:textStyle="bold" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Ingresa el correo electrónico con que te registraste en Así de Rápido, allí te enviaremos las instrucciones sobre como recuperar tu contraseña." android:gravity="center" style="@style/BigSectionTitleText" android:textSize="15sp" android:layout_marginBottom="10dp" /> <EditText android:layout_width="match_parent" android:layout_height="40dp" android:hint="Dirección de correo electrónico" android:paddingBottom="5dp" android:paddingLeft="20dp" android:paddingTop="5dp" android:layout_marginBottom="10dp" android:background="@drawable/log_rounded_corners" /> <com.google.android.material.button.MaterialButton android:id="@+id/button_solicitar_correo_cambiar_contrasena" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:paddingBottom="10dp" android:layout_marginBottom="30dp" android:paddingTop="5dp" android:text="Pedir" android:textSize="15sp" android:textStyle="bold" app:cornerRadius="8dp" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@id/button_zelle_payment_carrito" app:rippleColor="@color/colorAccent" /> </LinearLayout> </ScrollView> </LinearLayout>
The androidmanifest.xml file for the activity:
<activity android:name="com.asiderapido.deliveryapp.LoginActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize"></activity>
The fragment of the sheet:
private var botonRecibirCorreo: MaterialButton? = null class RecuperarContraseñaBottomSheet : BottomSheetDialogFragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // get the views and attach the listene var root = inflater.inflate( R.layout.register_bottom_sheet, container, false ) botonRecibirCorreo = root.findViewById(R.id.button_solicitar_correo_cambiar_contrasena) botonRecibirCorreo!!.setOnClickListener(){ Toast.makeText( root.context, "OK", Toast.LENGTH_LONG ).show() } return root } companion object { fun newInstance(): RecuperarContraseñaBottomSheet { return RecuperarContraseñaBottomSheet() } } }
And here is how I call the bottom_sheet fragment in the activity:
recuperarContrasena = findViewById(R.id.view_recuperar_contraseña) recuperarContrasena!!.setOnClickListener(){ val addPhotoBottomDialogFragment = RecuperarContraseñaBottomSheet.newInstance() addPhotoBottomDialogFragment.show( supportFragmentManager, "add_photo_dialog_fragment" ) }