通知栏导致DrawerLayout和Activity问题

时间:2018-10-12 13:45:39

标签: android kotlin android-actionbar

我想在我的应用程序中添加自定义操作栏,因为我使用的是DrawerLayout,这是问题所在:

enter image description here

这是我的主题:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>

在活动的onCreate()中,我添加了:

   setContentView(R.layout.activity_talk)
   setSupportActionBar(toolbar)

activity_talk.xml

<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"
tools:openDrawer="start">

<include
    layout="@layout/app_bar_main"
    />

<include
    layout="@layout/activity_talks_child"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"/>

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

app_bar_main.xml:

<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TalksActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_red_dark"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/holo_red_dark"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/activity_talks_child" />

</android.support.design.widget.CoordinatorLayout>

我不知道如何对齐操作栏...

谢谢

2 个答案:

答案 0 :(得分:0)

您可以尝试添加

  

android:layout_marginTop

收件人:

<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"
tools:openDrawer="start">

这应该将整个抽屉布局向下推。

答案 1 :(得分:0)

我终于找到了解决方法。

A在>> [P,H] = signrank(algo_err,benchmark_err); >> P P = 1 >> Win = sum(algo_err < benchmark_err) Win = 3 >> Equal = sum(algo_err == benchmark_err) Equal = 0 >> Loss = sum(algo_err > benchmark_err) Loss = 27 的{​​{1}}上添加了android:fitsSystemWindows="true"

我还在ConstraintLayout文件的第一个元素(这是app_bar_main.xml中包含的headerLayout)中添加了这一行(android:fitsSystemWindows="true")。