BottomSheetDialog 在底部可见,即使在 Android 10 上处于隐藏状态
BottomSheetDialog visible in bottom even in hidden state on Android 10
图片解释:-
- 登录按钮 = 显示登录视图
- 注册按钮 = 显示注册视图
- 忘记密码底部sheet
(图片经过编辑以隐藏徽标)
问题 = BottomSheetFragment 在底部可见
测试的设备 = Samsung、RealMe = 均具有 android 10
欢迎页面XML
<?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
所有片段中使用的代码
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior"
还实现了此 theme
以具有自定义设计 sheet 并具有默认的不可见背景 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>
也在 welcome
class
中尝试过这个
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
仍然看到底部的 BottomSheetDialogFragment
,这在像素为 android 10
的模拟器中不可见
由于某些原因
我需要在每个 BottomSheetDialogFragment
上使用 BottomSheetBehaviour
以在开始时隐藏它们
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
在每个 SheetFragment
上使用 BottomSheetBehaviour
并调用它后 onCreate()
解决了问题
图片解释:-
- 登录按钮 = 显示登录视图
- 注册按钮 = 显示注册视图
- 忘记密码底部sheet
(图片经过编辑以隐藏徽标)
问题 = BottomSheetFragment 在底部可见 测试的设备 = Samsung、RealMe = 均具有 android 10
欢迎页面XML
<?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
所有片段中使用的代码
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior"
还实现了此 theme
以具有自定义设计 sheet 并具有默认的不可见背景 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>
也在 welcome
class
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
仍然看到底部的 BottomSheetDialogFragment
,这在像素为 android 10
由于某些原因
我需要在每个 BottomSheetDialogFragment
上使用 BottomSheetBehaviour
以在开始时隐藏它们
//using kotlin
forgotSheetBehavior.isHideable = true
forgotSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
在每个 SheetFragment
上使用 BottomSheetBehaviour
并调用它后 onCreate()
解决了问题