协调器布局导致下一个片段底部部分被剪切/从屏幕中剪切/移出


如果

片段 1 具有 CoordinatorLayout 和 CollapsingToolbarLayout,则从片段 1 到 Fragment2 的片段事务会导致 Fragment2 中的底部对齐按钮被剪切/切出屏幕。

如果我用线性布局替换协调器布局,Fragment2 中的问题就会消失

尝试删除片段事务自定义动画。 仍然无法正常工作

片段1.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/htab_maincontent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layoutDirection="rtl"
    android:textDirection="ltr">
    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/htab_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">
        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/htab_collapse_toolbar"
            android:layout_width="match_parent"
            android:layout_height="259dp"
            android:background="#fff"
            app:contentScrim="#fff"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:titleEnabled="false">
            <cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager
                android:id="@+id/autoScrollViewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="parallax" />

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
            <!--toolbar content-->

            </androidx.appcompat.widget.Toolbar>

        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>
    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingBottom="10dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <!-- content-->
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

片段2.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layoutDirection="rtl"
    android:orientation="vertical"
    android:textDirection="rtl"
    tools:context=".RFQFragment">
    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
           <!--toolbar content-->
    </androidx.appcompat.widget.Toolbar>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="16dp"
            android:paddingRight="16dp">

<!-- content-->

        </LinearLayout>
    </androidx.core.widget.NestedScrollView>
    <Button
        android:id="@+id/send"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="8dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="16dp"
        android:background="@drawable/button_bg_enabled"
        android:gravity="center"
        android:text="@string/send"
        android:textAllCaps="false"
        android:textColor="@color/enable_able_text_color_selector"
        android:textSize="18dp"
        />

</LinearLayout>

删除android:fitsSystemWindows="true"解决了这个问题

最新更新