【问题标题】:How to avoid flickering/blinking while showing or dismissing alertDialog from bottomSheetDialogFragment从bottomSheetDialogFragment显示或关闭alertDialog时如何避免闪烁/闪烁
【发布时间】:2020-03-30 09:08:26
【问题描述】:

从我的 BottomSheetDialogFragment 显示/关闭警报对话框时,屏幕上会闪烁,如何避免这种情况?提前致谢。

AlertDialog alertDialog = AlertDialog.Builder(activity)
.setMessage(messageStringId)
.setPositiveButton(positiveButtonTextId) { _, _, _ ->
//Action
}
.setNegativeButton(negativeButtonTextId) { _, _, _ ->
//Action
}
.create()

alertDialog.show()

问题:https://youtu.be/yR8XXgHchmA

【问题讨论】:

  • 如果您在问题中显示一些 gif 或视频,这将有助于理解。
  • @brijeshkumar 感谢您的建议,已更新视频链接

标签: android android-alertdialog android-bottomsheetdialog


【解决方案1】:

我猜你添加底页的方式有问题。我正在使用 BottomSheetDialogFragment 并且我没有看到任何闪烁。这是我的代码

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

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    show_dialog.setOnClickListener {
        AlertDialog.Builder(context!!)
            .setMessage("message")
            .setPositiveButton("ok", null)
            .setNegativeButton("cancel", null)
            .show()
    }
}
}

【讨论】:

    猜你喜欢
    • 2020-12-28
    • 2023-04-02
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-30
    相关资源
    最近更新 更多