SwipeRefreshLayout overlaps BottomAppbar

让人想犯罪 __ 提交于 2020-01-16 10:12:50

问题


I feel like I've tried everything to resolve this but I can't figure out how to have a Coordinatorlayout containing an bottom app bar and a constraintlayout that contains a swipe refreshlayout without the refresh layout overlapping the bottom app bar.

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:background="@color/colorWhite"
    tools:context=".departures.DeparturesActivity">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:background="@color/colorWhite"
        tools:context=".departures.DeparturesActivity">

        <RelativeLayout-with-some-stuff-in-it/>

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:id="@+id/departures_swiperefresh_layout"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintTop_toTopOf="parent"
            tools:layout_editor_absoluteX="0dp">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/departures_list"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:paddingLeft="@dimen/md_keylines"
                android:paddingTop="@dimen/md_keylines"
                android:paddingRight="@dimen/md_keylines"
                android:paddingBottom="@dimen/md_keylines" />

        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>


    </androidx.constraintlayout.widget.ConstraintLayout>


    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/departures_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundTint="@color/colorAccent"
        app:layout_anchor="@id/bottomAppBar"
        app:srcCompat="@drawable/ic_add"
        app:tint="@color/colorWhite" />

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:backgroundTint="@color/colorPrimary"
        app:fabAlignmentMode="end"
        app:fabCradleMargin="4dp"
        app:fabCradleRoundedCornerRadius="16dp"
        app:fabCradleVerticalOffset="4dp"
        app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
        app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

The SwipeRefreshLayout will overlap the bottom app bar and I cant quite figure out why.

Part of the problem is the fact that the UI designer seems to indicate that the constraintlayout expands way below the coordinatorLayout.

This is due of the padding added here to push the layout below the actionbar.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".departures.DeparturesPresenter">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    </com.google.android.material.appbar.AppBarLayout>


    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/contentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingTop="?android:attr/actionBarSize" />


</androidx.constraintlayout.widget.ConstraintLayout>

来源:https://stackoverflow.com/questions/59591995/swiperefreshlayout-overlaps-bottomappbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!