android How DialogFragment displays the words on the status bar on a white background?

Viewed 91

Before loading,The font of the status bar of the normal page is displayed

After loading 'Why is the font in the status bar invisible?'

The project theme background is white, the status bar is transparent, and the words in the status bar of the loading page using DialogFragment are not visible. How to solve this?

My expectation is that only the middle loading box appears, the words on the status bar are displayed normally, and the entire DialogFragment is completely transparent; thank you

class LoadingDialog(var message: String? = null) : DialogFragment() {

override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?,
): View {
    val binding = LoadingViewBinding.inflate(inflater, container, false)
    val tvContent = binding.loadingViewTvContent
    if (!message.isNullOrEmpty()) {
        tvContent.text = message
    }
    dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
    dialog?.window?.setDimAmount(0f)  //完全透明
    return binding.root
}

override fun onStart() {
    super.onStart()
    isCancelable = false    //点击外部不可取消
    val dm = DisplayMetrics()
    this.activity?.windowManager?.defaultDisplay?.getMetrics(dm)
    this.dialog?.window?.setLayout(dm.widthPixels, dm.heightPixels)
}  }
1 Answers

Check your code:

this.activity?.windowManager?.defaultDisplay?.getMetrics(dm)
this.dialog?.window?.setLayout(dm.widthPixels, dm.heightPixels)

When the dialog is created you set the layout size according to the device height & width. So, logially the dialog will shown up as fullscreen.

Also, you can show the LoadingDialog with Dialog only.

Follow this code: https://github.com/rommansabbir/ResultShowDialog-Android/blob/master/app/resultshowdialog/src/main/java/com/rommansabbir/resultshowdialog/ResultShowDialog.kt and change it according to your requirement.

Related