Java 工具栏重叠内容
需要帮助了解我的工具栏为什么与内容重叠Java 工具栏重叠内容,java,android,android-layout,Java,Android,Android Layout,需要帮助了解我的工具栏为什么与内容重叠 我在这里有一个工具栏布局 toolbar.xml <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/a
我在这里有一个工具栏布局
toolbar.xml
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/AppTheme">
</android.support.v7.widget.Toolbar>
工具栏到底出了什么问题?将
列表视图
放在工具栏包含后的线性布局中。那会使一切井然有序。我把它修好了。我不得不将抽屉布局
和工具栏
放在一个容器中,比如线性布局
,因为抽屉布局作为根悬停在(重叠)其他内容上。
我将导航_drawer.xml更改为
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_navigation_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.jlurena.yougothw.activities.base.NavigationDrawer">
<ListView
android:id="@+id/nav_list"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffeeeeee">
</ListView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
谢谢你的帮助,这让我想到了抽屉的实际布局。
public void inflateBaseLayout(Activity activity, int resLayoutId) {
LayoutInflater inflater =
(LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Inflate Navigation Drawer in activity
View view = inflater.inflate(resLayoutId, null, true);
drawer.addView(view, 0); // Where drawer is the DrawerLayout from navigation_drawer.xml
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_navigation_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.jlurena.yougothw.activities.base.NavigationDrawer">
<ListView
android:id="@+id/nav_list"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffeeeeee">
</ListView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>