gpt4 book ai didi

java - BottomSheet 在 styles.xml 中声明的 "android:background"上不透明

转载 作者:行者123 更新时间:2023-12-01 22:49:14 24 4
gpt4 key购买 nike

我处于以下情况:我有一个具有白色背景的应用程序,因此我在样式 xml 中声明了 android:background。

问题:我只想显示一个基本的底部表,但我注意到,当声明 android:background 时,底部表不透明。

底页

class SortListBottomSheet : BottomSheetDialogFragment(){
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.sort_list_bottom_sheet, container, false)
}
}

主要 Activity

sortListFab.setOnClickListener {
val sortListBottomSheet = SortListBottomSheet()
sortListBottomSheet.show(supportFragmentManager, "test")
}

样式.xml

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:background">@android:color/white</item>
</style>

如何使我的bottomSheet透明?

感谢您的帮助。

最佳答案

好的,我找到了解决方案:

将其添加到 styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>

<style name="AppBottomSheetDialogTheme"
parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:background">@android:color/transparent</item>
</style>

这应该可以解决问题。

关于java - BottomSheet 在 styles.xml 中声明的 "android:background"上不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58463439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com