Missing Up navigation icon after switching from ICS ActionBar to Lollipop Toolbar

前端 未结 3 755
南旧
南旧 2020-12-29 11:13

I have an activity with many fragments that uses action bar and navigation drawer. It has \"home as up\" enabled. I have implemented proper logic that only top level fragmen

3条回答
  •  孤城傲影
    2020-12-29 11:30

    If you use AppCompatActivity, you can get the right drawer icon and back icon by

            if(homeUp)
        {
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            mDrawerToggle.setDrawerIndicatorEnabled(false);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressed();
                }
            });
    
        }
        else
        {
            mDrawerToggle.setDrawerIndicatorEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            mDrawerToggle.syncState();
        }
    

    Without need for getV7DrawerToggleDelegate :D

提交回复
热议问题