blurkit-android icon indicating copy to clipboard operation
blurkit-android copied to clipboard

我在Dialog中使用!I use it in Dialog! The background is not right. Look at the picture.

Open xuxh6 opened this issue 5 years ago • 3 comments

我在Dialog中使用!背景效果不对,看图片 I use it in Dialog! The background is not right. Look at the picture.

xuxh6 avatar Jun 27 '19 02:06 xuxh6

image

xuxh6 avatar Jun 27 '19 02:06 xuxh6

怎样正确的在Dialog中使用? How to use it correctly in Dialog?

xuxh6 avatar Jun 27 '19 02:06 xuxh6

怎样正确的在Dialog中使用? How to use it correctly in Dialog?

Hi! I've been using another library, but there are 2 solutions:

  1. Every time you open a dialog, show another full-screen dialog with blur view. It's quite easy: You can try to create an abstract dialog class that all your dialogs will extend, override methods show and onDismiss with onCancel for showing and hiding your custom BlurDialog Example:
abstract class BlurDialogFragment : DialogFragment() {
    private var blurDialog: BlurDialog? = null

    override fun show(manager: FragmentManager, tag: String?) {
        initBlurDialog(manager.beginTransaction())?.let {
            super.show(it, tag)
        }
    }

    override fun show(transaction: FragmentTransaction, tag: String?): Int {
        return initBlurDialog(transaction)?.let {
            super.show(it, tag)
        } ?: -1
    }

    override fun onCancel(dialog: DialogInterface) {
        blurDialog?.dismiss()
        super.onCancel(dialog)
    }

    override fun onDismiss(dialog: DialogInterface) {
        blurDialog?.dismiss()
        super.onDismiss(dialog)
    }

    private fun initBlurDialog(transaction: FragmentTransaction): FragmentTransaction? {
        if (blurDialog != null)
            return null

        blurDialog = BlurDialog.getInstance()

        transaction
                .add(blurDialog!!, BlurDialogTag)

        return transaction
    }
}

Note! If you decide to implement this idea, BlurDialog is another dialog and you should declare and set appropriate style:

    <style name="FullScreenDialogStyle" parent="Theme.AppCompat.Dialog">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowIsFloating">false</item>
        <item name="android:windowBackground">@color/transparent</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NORMAL, R.style.FullScreenDialogWithFadeStyle)
    }
  1. Create one dialog for blur and your content, a full-screen dialog, where you have to set all margins for content manually. I suppose 1st method is better and easier

flaringapp avatar Jul 03 '19 08:07 flaringapp