mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.06k forks source link

about StatusBar #2465

Closed woleigeququ closed 5 years ago

woleigeququ commented 5 years ago

i want to : public abstract class BaseActivity extends AppCompatActivity { ... setContentView(initView());

    StatusBarUtil.setRootViewFitsSystemWindows(BaseActivity.this,true);
    StatusBarUtil.setTranslucentStatus(BaseActivity.this);

...

then other activities can display normally , but the MainActivity which create drawer is like this :

problem

the top of drawer is normal but main page isn't so could anyone help me ? thanks a lot .

Okami-x-Senpai commented 5 years ago

That's because you are using a dependency that is not MaterialDrawer. To make the notification bar transparent when you open the menu you have to put this line of code in your MaterialDrawer constructor:

        mMainMenu = new DrawerBuilder()
                .....
                .withToolbar(toolbar)
                .withTranslucentStatusBar(true)
                .withTranslucentNavigationBar(true)

I hope it works for you. :)

woleigeququ commented 5 years ago

i did that , but the problem still. then i set the backgound color of mainactivity to yellow.. it looks normal.. I used to think it would automatically turn yellow , just like other activity , i don't know much about it . (ㄒoㄒ)

Okami-x-Senpai commented 5 years ago

Try adding

android:fitsSystemWindows="true"

In the main layout of the activity.

woleigeququ commented 5 years ago

i set it in baseactivity after setContentView public static void setRootViewFitsSystemWindows(Activity activity, boolean fitSystemWindows) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ... rootView.setFitsSystemWindows(fitSystemWindows); }} i tried to set it in xml, they have the same effect

mikepenz commented 5 years ago

@woleigeququ you use the proper theme?

woleigeququ commented 5 years ago

it's my setting of theme : android:theme="@style/AppNoTitleTheme"

is that correct ? and .. i didn't use toolbar , so i didn't set "withToolbar(toolbar)" , does it affect the display?

mikepenz commented 5 years ago

You might also want to see comments here: https://github.com/mikepenz/MaterialDrawer/issues/2473