Tapadoo / Alerter

An Android Alerting Library
MIT License
5.52k stars 632 forks source link

status bar is not overriden from alert #283

Open SoftwareAdvise opened 2 years ago

SoftwareAdvise commented 2 years ago

hi all, i have a problem regarding status bar not overriden by alert, why this happen?

immagine

thanks.

ryankamanri commented 2 years ago

I found a solution (not good, just solve) observe Alerter.show()

    public Alert show() {
        //This will get the Activity Window's DecorView
        if (getActivityWeakReference() != null) {
            getActivityWeakReference().get().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Add the new Alert to the View Hierarchy
                    final ViewGroup decorView = getActivityDecorView();
                    if (decorView != null && getAlert().getParent() == null) {
                        decorView.addView(getAlert());
                    }
                }
            });
        }

        return getAlert();
    }

It is found that the View of this Alert has been added to the window.decorView You can find the Alert object by traversing the window.decorView and set its translationZ

So i solved the problem, by:

val children = (window.decorView as ViewGroup).children
        children.forEach {
            if(it.javaClass == Alert::class.java) {
                (it as Alert).translationZ = 100f
            }
        }

Maybe you can wrap it better.