BottomsheetDialog没有样式或本地化

问题描述

我有一个Bottomsheetdialog,它既不会更改为深色模式,也不会更改语言。难道我做错了什么? onclick侦听器正在运行。 Kotlin代码

private fun outsideDoorModalShow() {
        val bottomSheetDialog = BottomSheetDialog(activity,R.style.BottomSheetDialogTheme)
        val bottomSheetView = LayoutInflater.from(activity.applicationContext).inflate(
                R.layout.outside_door_bottom_modal,null
        )

        bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
        bottomSheetView.findViewById<Button>(R.id.order_outside_door_button_order).setonClickListener { orderOutsideDoor(bottomSheetDialog) }
        bottomSheetDialog.setContentView(bottomSheetView)
        bottomSheetDialog.show()
    }

xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/outside_door_modal_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bottom_sheet_background"
    android:orientation="vertical">


/.../


    <Button
        android:id="@+id/order_outside_door_button_order"
        style="@style/OnboardingButtonAppearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="32dp"
        android:text="@string/order" />

</LinearLayout>

解决方法

弄清楚了。不得不替换

val bottomSheetView = LayoutInflater.from(activity.applicationContext).inflate(
                R.layout.outside_door_bottom_modal,null
        )

使用

val bottomSheetView = LayoutInflater.from(activity).inflate(
                R.layout.outside_door_bottom_modal,null
        )

```