DebugDrawer icon indicating copy to clipboard operation
DebugDrawer copied to clipboard

android:windowTranslucentStatus not working

Open dejandobnikar opened this issue 8 years ago • 3 comments

Hi,

android:windowTranslucentStatus is not working when debug drawer attached to activity.

What is the reason for this? How to solve this?

dejandobnikar avatar Dec 21 '16 22:12 dejandobnikar

Not just that. Also other style configurations with non-standard status bar. The DrawerLayout injected at the root of the hierarchy is a bit intrusive and overrides some parameters. I would prefer some less intrusive method like a sticky notification. Right-side sliding is used by quite many apps.

sevar83 avatar Feb 11 '17 12:02 sevar83

Did anyone forked the project and make it work with transparent/translucent status bar? It took me a couple of hours before I realized that this library was interfering with my app to show a transparent status bar.

kaciula avatar Oct 29 '18 13:10 kaciula

The problem is that their DrawerLayout consume window insets and they don't get passed on to the actual content.

I just leave this here:

DebugDrawer.Builder(activity)
        .modules(
                BuildModule(),
                DeviceModule(),
                TimberModule(),
                SettingsModule()
        ).build()

// DebugDrawer breaks translucent status bar on Common onboarding screen. They
// internally use [ScrimInsetsFrameLayout] which consumes insets. Make sure insets
// get passed to children as well.
val content: ViewGroup? = activity.findViewById(R.id.dd_content_layout) as? ViewGroup
val parent: ViewGroup? = content?.parent as? ViewGroup
content?.redispatchWindowInsetsToAllChildren()
parent?.redispatchWindowInsetsToAllChildren()
/**
 * Fixes a problem with fitsSystemWindows where only the first view in viewHierarchy has a chance
 * to offset itself away from Status and Navigation bars. Typically when a view is defined
 * to fitsSystemWindows, it consumes those offsets, leaving no offsets for other views.
 * Listen for dispatch of WindowInsets and redispatch the offsets to all children. Even if the first
 * child consumes offsets, other children get the original offsets and can react accordingly as well.
 */
fun ViewGroup.redispatchWindowInsetsToAllChildren() {
    ViewCompat.setOnApplyWindowInsetsListener(this) { view, insets ->
        var consumed = false
        val parent = view as ViewGroup

        for (i in 0 until parent.childCount) {
            val child = parent.getChildAt(i)
            // Dispatch the insets to the child
            val childResult = ViewCompat.dispatchApplyWindowInsets(child, insets)
            // If the child consumed the insets, record it
            if (childResult.isConsumed) {
                consumed = true
            }
        }

        // If any of the children consumed the insets, return an appropriate value
        if (consumed) insets.consumeSystemWindowInsets() else insets
    }
}

This fixes the problem where status bar and navigation bar are not transparent. But the drawer's content is now also drawn behind the status and navigation bars, which is okay with me.

Antimonit avatar Feb 07 '19 14:02 Antimonit