工具栏与android中的状态栏重叠

时间:2016-06-11 14:22:07

标签: android toolbar android-collapsingtoolbarlayout

我已经使用工具栏实现了collapsingToolbarLayout。问题是工具栏在状态栏下方重叠。我已经在stackoverflow上读了其他相关的问题(android:fitsSystemWindows =“true”),但有些事情是错误的,它们不能解决我的问题。

这是我的活动xml:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true" >

  <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="16dp"
        app:expandedTitleMarginEnd="0dp"
        app:expandedTitleMarginBottom="40dp"
         app:collapsedTitleGravity="start"
       app:collapsedTitleTextAppearance="@style/colapsedTextAprearance"
        app:expandedTitleTextAppearance="@style/expandedTextAprearance"
        android:fitsSystemWindows="true"
 >
   <TextView
            android:id="@+id/subtitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="16dp"
            />
  <include
        android:id="@+id/toolbar"
        layout="@layout/peyvtoolbar"

        />

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

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

和peyvtoolbar.xml是:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:layout_collapseMode="pin"
    >


</android.support.v7.widget.Toolbar>

enter image description here

0 个答案:

没有答案
相关问题