更改 BottomSheetDialogFragment 的稀松布颜色

问题描述 投票:0回答:2

如何更改

BottomSheetDialogFragment
稀松布颜色 - 暗淡的覆盖颜色?

您可以通过

DrawerLayout
drawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.dimOverlay))

执行此操作

enter image description here

android bottom-sheet
2个回答
4
投票

您可以更改

Window
的背景并设置您想要的透明颜色。

@Override
public @NotNull Dialog onCreateDialog(Bundle savedInstanceState){
    BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
    Window window = dialog.getWindow();
    window.setBackgroundDrawableResource(R.color.colorPrimaryTransparent);
    return dialog;
}

0
投票
class AppointmentBottomSheet : BottomSheetDialogFragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view =
            inflater.inflate(R.layout.appointment_modal_bottom_sheet_content, container, false)
        dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.BLUE)) //--> set any color you want here`enter code here`
        return view
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.