Issue
Explaining the image:-
- Login button = To show login view
- Sign up button = To show sign up view
- Forgot Password bottom sheet
(Image is edited to hide logos)
Problem = BottomSheetFragment is visible in bottom
Devices tested = Samsung, RealMe = both with android 10
XML
of welcome page
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".welcome.Welcome">
<include layout="@layout/activity_welcome_content" />
<include layout="@layout/fragment_sign_in" />
<include layout="@layout/fragment_sign_up" />
<include layout="@layout/fragment_forgot_password" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
xml
code using in all fragments
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior"
Also implemented this theme
to have a custom design of sheet and have a invisible background of default sheet
<style name="AppBottomSheetTheme" parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>
<style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@color/trans</item>
<item name="behavior_hideable">true</item>
<item name="behavior_peekHeight">500dp</item>
</style>
Also tried this in welcome
class
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
Still seeing the BottomSheetDialogFragment
in the bottom, this is not visible in the emulator of pixel with android 10
Solution
Due to some reason
I needed to use BottomSheetBehaviour
on every BottomSheetDialogFragment
to hide them on start
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
After using BottomSheetBehaviour
on every SheetFragment
and calling it onCreate()
solved the problem
Answered By – Rahul Gaur
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0