ActionBarDrawerToggle is being shown only while swiping(moving) drawer

58 views Asked by At

I have problem with drawer indicator in toolbar.
The icon (hamburger) is visible only while moving (swiping) drawer view, and becomes invisible on stop.
Here is screenshot

https://i.stack.imgur.com/i4ihv.jpg

And while moving it becomes visible

https://i.stack.imgur.com/kOTLG.jpg

If stop move drawer view it becomes invisible again.

Here is my setup code

    mToolbar.setVisibility(View.VISIBLE);
    mToolbar.setTitle(getToolbarTitle());
    setSupportActionBar(mToolbar);
    if (hasDrawerToggle()) {
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerMainLayout,
                R.string.drawer_open, R.string.drawer_close);
        mDrawerToggle.setDrawerIndicatorEnabled(true);
        mDrawerMainLayout.setDrawerListener(mDrawerToggle);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }



@Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        if (hasDrawerToggle()) {
            mDrawerToggle.syncState();
        }
    }

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (hasDrawerToggle()) {
        mDrawerToggle.onConfigurationChanged(newConfig);
    }
}
1

There are 1 answers

2
Jaykishan Sewak On

Why are you using hasDrawerToggle() condition?

The problem may due to your condition, so try by removing condition from all places like onPostCreate,onCreate etc.

Hop it will work.