Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有AppBarLayout和工具栏的新Android设计库bug_Android_Android Layout_Android Toolbar_Android Design Library - Fatal编程技术网

带有AppBarLayout和工具栏的新Android设计库bug

带有AppBarLayout和工具栏的新Android设计库bug,android,android-layout,android-toolbar,android-design-library,Android,Android Layout,Android Toolbar,Android Design Library,我正在github和中使用基于此示例的新Android设计库 我已经运行了这个示例,但我在CheesedDelactivity内的工具栏上遇到了问题。工具栏没有按应有的方式显示。请看下面的图片: 首先,您可以看到工具栏显示不正确 在第二个图像中,您可以看到工具栏显示正确,但通知栏为白色。之所以会出现这种情况,是因为我从actiivty_detail.xmlandroid:fitsystemwindows=“true”中删除了android.support.design.widget.Coord

我正在github和中使用基于此示例的新Android设计库

我已经运行了这个示例,但我在CheesedDelactivity内的工具栏上遇到了问题。工具栏没有按应有的方式显示。请看下面的图片:

首先,您可以看到工具栏显示不正确

在第二个图像中,您可以看到工具栏显示正确,但通知栏为白色。之所以会出现这种情况,是因为我从actiivty_detail.xml
android:fitsystemwindows=“true”
中删除了android.support.design.widget.CoordinatorLayout

我认为
fitsystemwindows
应该是正确的,问题与
android.support.design.widget.AppBarLayout
有关,但我不知道如何解决这个问题。我试着用
marginTop
notificationBar
一样高,但没用

如有任何建议,我们将不胜感激:)

这是
活动\u detail.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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/detail_backdrop_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    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"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin" />

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

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

看起来这是
com.android中的一个bug。支持:设计:22.2.0
。 它将被修复,并被标记为未来版本。所以,让我们期待它很快就会到来。 与问题的联系:

在windowActionBar和windowNoTitle中也出现了同样的问题,并解决了我的问题

<style name="AppTheme.base" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
       <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

@颜色/原色
@颜色/原色暗
@颜色/颜色重音
假的
真的

以下是API 21的一些解决方法:

 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
    marginResult = 0;
    int resourceId = getResources().getIdentifier(getString(R.string.identifier_status_bar_height), getString(R.string.identifier_dimen), getString(R.string.identifier_android));    
    if (resourceId > 0) {
        marginResult = getResources().getDimensionPixelSize(resourceId)*2;
     }
    CollapsingToolbarLayout.LayoutParams params = (CollapsingToolbarLayout.LayoutParams) mToolbar.getLayoutParams();
    params.topMargin -= marginResult;
    mToolbar.setLayoutParams(params);}
使用新版本build.gradleapp文件夹中更改设计库,如:

编译'com.android.support:design:22.2.1'

更新于

我得到了如下输出:

它会帮助你的


谢谢:)

我也遇到了同样的问题,我的工具栏在API级别大于21时显示错误。我将android.support.v7.widget.Toolbar用作supportActionBar(),下面的内容是片段,请参见图片: 及

当我将android:fitsystemwindows=“true”属性添加到工具栏所在视图的根元素时,我解决了这个问题

现在: 及

你在哪里设置了
应用程序:布局\u行为
?我没有显示所有的xml,但你可以在这里找到它:我不想更改状态栏的颜色,我希望它看起来像这样:我明白了
android:fitsystemwindows=“true”
AppBarLayout
上,因为您希望它位于状态栏后面,并且
android:fitsystemwindows=“false”
工具栏上的
因为你没有。希望他们能尽快解决:)@Ultimo\u m有更新吗?@PratikButani他们根据这篇文章进行了更新我还没有检查它是否解决了这个问题我还没有测试它,但这一定是解决方案:)android支持设计库版本22.2.1没有为我解决这个问题。我在运行安卓5.0的设备上又遇到了麻烦。我必须更新到23.1.0。现在可以用了