折叠式工具栏布局状态栏问题

5
我不知道为什么,但是当工具栏折叠时似乎会出现第二个状态栏。
我在所有组件中都使用了android:fitsSystemWindows="true",因为如果没有这个属性,工具栏会从状态栏中出来。
以下是一些图片以更好地解释: 图片 我从未见过这样的事情,我尝试了所有方法,但我不知道如何解决它。我在网上也找不到任何信息。
以下是代码:
布局:
<android.support.design.widget.CollapsingToolbarLayout
    android:id="@+id/collapsing_toolbar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    app:statusBarScrim="?attr/colorPrimaryDark"
    app:contentScrim="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|exitUntilCollapsed" >

    <ImageView
        android:id="@+id/photo_actor"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:fitsSystemWindows="true"
        app:layout_collapseMode="parallax" />
    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_collapseMode="parallax"
        android:fitsSystemWindows="true"
        android:background="@drawable/background_protection" />
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:fitsSystemWindows="true"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="8dp"
        android:orientation="vertical">
        <WebView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@null"
            android:id="@+id/webview_bio"/>
    </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

Activity onCreate:

在活动创建时:
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    if(collapsingToolbarLayout!=null){
        collapsingToolbarLayout.setTitle(advm.getName());
    }

样式:(我在当前活动中使用的是第二个)

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColor">@color/text_color</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
2个回答

1
在CollapsingToolbarLayout中,fitSystemWindows()增加了额外的填充。我认为你需要在主题级别(API19+)启用<item name="android:windowTranslucentStatus">true</item>,以获得与全屏模式相同的稳定布局。请注意,保留html标签。

0

如果遇到这个问题,请将以下内容添加到父元素中:

android:fitsSystemWindows="true"

在上面的代码中,我认为应该是:
<android.support.design.widget.AppBarLayout 
android:fitsSystemWindows="true"
...
>
...
</android.support.design.widget.AppBarLayout>

祝你好运,'。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接