Possible problematic style of Toolbar

2019-08-30 09:30发布

问题:

This case is related to the following problem. In the case I believe it may be a problem with the style I'm trying to use the toolbar. I need you to stay in the Toolbar overlay, it has a drawer menu, and the lollipop operate normally, lower some versions.

style.xml v21

<style name="AppTheme" parent="AppTheme.Base">
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowActionModeOverlay">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

        <!-- enable window content transitions -->
        <item name="android:windowContentTransitions">true</item>

    </style>

style.xml

<!-- Base application theme. -->
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="colorAccent">@color/accent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowActionModeOverlay">true</item>
        <item name="android:windowContentTransitions">true</item>
    </style>

    <style name="AppTheme" parent="AppTheme.Base">
    </style>

If you are ok, someone could help me in this case the toolbar and the drawer disappear?

回答1:

I found the solution to my problem. It was a possible conflict in style but rather a problem of organizing the objects on the screen. With this following code could play the elements that disappeared in front of the camera.

        getActivity().findViewById(R.id.DrawerLayout).bringToFront();
        getActivity().findViewById(R.id.DrawerLayout).invalidate();
        getActivity().findViewById(R.id.DrawerLayout).requestLayout();

In this case I have to get the reference of DrawerLayout and not the Toolbar. Thus the issue is resolved.