小编Pro*_*lus的帖子

FitsSystemWindows 不工作

我想设置FitsSystemWindows = true我的工具栏或/和更改通知栏颜色。但这不起作用。我想做的事:图片

我的代码在这里: 样式

<!-- Base application theme. -->
<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="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimary">@color/colorWhite</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
Run Code Online (Sandbox Code Playgroud)

ActivityDrawerLayout - 其他活动的基础活动

<android.support.v4.widget.DrawerLayout ...
    android:fitsSystemWindows="true"
    tools:context="com.peter.freshNews.activity.DrawerActivity">

    <android.support.design.widget.NavigationView ...
        android:background="@color/drawer_background"
        android:fitsSystemWindows="true"
        app:menu="@menu/drawer_menu" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

活动主体

<FrameLayout ...
android:fitsSystemWindows="true">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    android:fitsSystemWindows="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.view.ViewPager.../>

    <include layout="@layout/toolbar" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

工具栏

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

    <android.support.design.widget.CollapsingToolbarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:collapsedViewOffset="0dp"
        app:contentScrim="?attr/colorPrimary"
        app:expandedViewOffset="0dp"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ViewSwitcher …
Run Code Online (Sandbox Code Playgroud)

java android android-support-library android-support-design

5
推荐指数
1
解决办法
6706
查看次数