CoordinatorLayout 导致下一个片段底部剪切/超出屏幕
CoordinatorLayout causes next fragment bottom part cut / out of screen
如果 Fragment1 具有 CoordinatorLayout 和 CollapsingToolbarLayout,则从 Fragment1 到 Fragment2 的片段事务会导致 Fragment2 中底部对齐的按钮切出/超出屏幕。
如果我用 LinearLayout 替换 CoordinatorLayout,Fragment2 中的问题就会消失
已尝试删除片段交易自定义动画。仍然无法正常工作
fragment1.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>
fragment2.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" 解决了问题
如果 Fragment1 具有 CoordinatorLayout 和 CollapsingToolbarLayout,则从 Fragment1 到 Fragment2 的片段事务会导致 Fragment2 中底部对齐的按钮切出/超出屏幕。
如果我用 LinearLayout 替换 CoordinatorLayout,Fragment2 中的问题就会消失
已尝试删除片段交易自定义动画。仍然无法正常工作
fragment1.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>
fragment2.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" 解决了问题