Reputation: 196
I want to use material drawer like about 30 times I already used it. If I put materialDrawer builder in OnCreate method all work well. Building drawer after some seconds with thread a CountDown timer produces a white grey space in statusbar.
My simple code to build it:
result = new DrawerBuilder(this)
.withActivity(this)
.withToolbar(toolbar)
.withActionBarDrawerToggle(true)
.addDrawerItems(
My values-21 Activity Style:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
My activity_main.xml: Watch at fitSystemWindows="true". Using this attribute in CoordinatorLayout
solve statusbar issue. But the same space is on bottom of xml now. Removing it from coordinator, cause the issue on statusbar and not anymore in bottom layout.
Upvotes: 0
Views: 134
Reputation: 12868
You must not do UI manipulation on a non-UI thread in Android. You can have some more reading about this here: https://developer.android.com/training/multiple-threads/communicate-ui.html
In general it should help if you put the code inside a handler so it is executed on the main thread:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//your code
}
}, 1);
But in fact I would recommend that you create your drawer in your onCreate
method. If you do not have the information about the items yet at this place you just can add them at a later time using the Drawer
object too. You can find some samples on how to modify the drawer after building here: https://github.com/mikepenz/MaterialDrawer#modify-items-or-the-drawer
You might also want to check out the javadoc for the Drawer
http://static.javadoc.io/com.mikepenz/materialdrawer/5.3.1/com/mikepenz/materialdrawer/Drawer.html
Upvotes: 1