[英]Navigation Drawer below Status Bar
I'm tring to make a Navigation Drawer using Design Support Library. 我打算使用设计支持库制作一个导航抽屉。 In my activity_main i wrote this code.
在我的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>
When i run my application it works and show the Navigation Drawer but it's below the Status Bar and not above. 当我运行我的应用程序时,它可以工作并显示导航抽屉,但它在状态栏下面而不是上面。 How can i move it to stay above the StatusBar?
我如何将其移动到状态栏上方?
只需将android:fitsSystemWindows =“ false”添加到DrawerLayout即可解决问题
Make your activity as full screen to overcome status bar as below or any other method as available on WWW: but it's not good to have drawer over status bar. 将您的活动设置为全屏显示,以克服以下状态栏或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.