安卓导航抽屉没有显示标题栏在kitkat

问题描述:

在我的应用程序中,我创建了一个使用Android工作室模板的导航抽屉。 它完美的是Android 5.0以上的设备,但标题栏没有出现在奇巧设备(仅限斯塔提乌斯栏可以看出),我无法找到一个解决方案,安卓导航抽屉没有显示标题栏在kitkat

以下是我的代码

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 
     getSupportActionBar().show(); 


     DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
     ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
       this, drawer, toolbar,R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
     drawer.setDrawerListener(toggle); 
     toggle.syncState(); 

     navigationView = (NavigationView) findViewById(R.id.nav_view); 
     navigationView.setNavigationItemSelectedListener(this); 

     Intent intent = getIntent(); 
     linkNo = intent.getIntExtra(FirstMenuFragment.LINK_NO, 0); 
     //Make firstItem active 
     navigationView.getMenu().getItem(linkNo).setChecked(true); 

    } 

在此先感谢

在KitKat中,使状态栏(半)透明比Lollipop +更复杂。所以标题栏仍然存在,它只是在状态栏下方;)

编辑:如果您绝对想在KitKat上实现此目的,则可以使用SystemBarTintManager(https://github.com/jgilfelt/SystemBarTint/blob/master/library/src/com/readystatesoftware/systembartint/SystemBarTintManager.java)。

但我不建议,我自己做过,并不容易做到。