0

レイアウトに奇妙なバグがあり、それを理解できません。Fragments と TabLayout の間に白いバーが表示されます。このコードをしばらく変更していませんでした。おそらく Android 6.0.1 の何かです (私は Nexus 5 を持っています)。6.0 にも Lollipop にもバグはなかったと確信しています。

スクリーンショットは次のとおりです。

ここに画像の説明を入力

これは私のアクティビティ XML です。

<?xml version="1.0" encoding="utf-8"?>
<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.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_below="@+id/tablayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        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="142dp"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginBottom="20dp"
            app:expandedTitleMarginEnd="48dp"
            app:expandedTitleTextAppearance="@style/ExpandedText"
            app:collapsedTitleTextAppearance="@style/CollapsedText">
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"/>
            </android.support.design.widget.CollapsingToolbarLayout>
        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/toolbar"
            android:minHeight="?attr/actionBarSize"
            android:gravity="bottom"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:tabIndicatorColor="?attr/colorPrimaryDark"/>
        </android.support.design.widget.AppBarLayout>
    </android.support.design.widget.CoordinatorLayout>

何か案が?

更新 1:

@Abanoub Samaan の提案の後、私のレイアウトは次のようになります。

ここに画像の説明を入力

更新 2:

このバグは、Android 5.1.1 Lollipop を実行している Nexus 7 (2012) でも発生します。

4

4 に答える 4

3

Abdelalim のように、私は別の状況で同じ問題を抱えていました。

私の主な活動では、

<RelativeLayout>
    <FragmenLayout></FrameLayout>
    <android.support.design.widget.BottomNavigationView><android.support.design.widget.BottomNavigationView
</RelativeLayout>

フレームレイアウトでいくつかのフラグメントがレンダリングされました。フラグメントの1つに、CoordinatorLayoutがありました

android:fitsSystemWindows="true"

それを削除しただけで機能しました

于 2017-12-22T09:45:55.003 に答える
2

CollapsingToolbarLayout の高さを設定しないでください

android:layout_height="142dp"

で置き換えます

android:layout_height="wrap_content"
于 2016-05-26T10:23:21.020 に答える