Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NavigatonView] Bottom scrim is always displayed when setting android:theme #1627

Closed
tadfisher opened this issue Aug 18, 2020 · 0 comments
Closed
Labels

Comments

@tadfisher
Copy link
Contributor

Description: NavigationView has logic to determine whether to display the insetForeground scrim in the bottom system window inset. This logic does not apply when android:theme is set for the view, as it is checking that the view's context is an instance of Activity, and setting a theme on the view replaces the context with a ContextThemeWrapper.

Expected behavior: When setting android:theme on a NavigationView with a non-transparent navigationBarColor applied to the window, the view should not draw insetForeground in the bottom system window inset area.

Source code: From NavigationView.java, in setupInsetScrimsListener:

        Context context = getContext();
        if (context instanceof Activity && VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
          boolean isBehindSystemNav =
              ((Activity) context).findViewById(android.R.id.content).getHeight()
                  == getHeight();
          boolean hasNonZeroAlpha =
              Color.alpha(((Activity) context).getWindow().getNavigationBarColor()) != 0;

          setDrawBottomInsetForeground(isBehindSystemNav && hasNonZeroAlpha);
        }

If the Context is actually a ContextThemeWrapper or ContextWrapper instance, the logic is not performed and the view will draw the bottom inset foreground by default.

Android API version: 29

Material Library version: 1.2.0

Device: Pixel 2 XL

@tadfisher tadfisher added the bug label Aug 18, 2020
dsn5ft pushed a commit that referenced this issue Aug 28, 2020
Resolves #1628
Resolves #1627

GIT_ORIGIN_REV_ID=4042d13c8326144184e46795b217b9172b6552ad
PiperOrigin-RevId: 327446397

(cherry picked from commit a6a750b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant