繁体   English   中英

状态栏下方的导航抽屉

[英]Navigation Drawer below Status Bar

我打算使用设计支持库制作一个导航抽屉。 在我的activity_main中,我编写了此代码。

<?xml version="1.0" encoding="utf-8"?>

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"  
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

    <LinearLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"/>

    <FrameLayout 
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>   

    </LinearLayout>

   <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/header_layout"
        app:menu="@menu/menu_drawer"/>  

    </android.support.v4.widget.DrawerLayout>

当我运行我的应用程序时,它可以工作并显示导航抽屉,但它在状态栏下面而不是上面。 我如何将其移动到状态栏上方?

只需将android:fitsSystemWindows =“ false”添加到DrawerLayout即可解决问题

将您的活动设置为全屏显示,以克服以下状态栏或WWW上可用的任何其他方法:但是,在状态栏上放置抽屉并不好。

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM