I have a RecyclerView list of cardviews and recently Android Studio recommended an update to "implementation 'androidx.core:core:1.12.0'" from 1.10.1.
A layout issue then appeared in Studio: a Render problem showed up and was only solved by moving the "app:layout_behavior="@string/appbar_scrolling_view_behavior" code line from the RelativeLayout that is holding the RecyclerView to the AppBarLayout section.
Two new problems resulted from moving the appbar_scrolling_view_behavior code line to the AppBarLayout:
the RecyclerView is pushed all the way up to right underneath the AppBarLayout/Toolbar so that the three TextViews are covered over. The three TextViews are basically headers for the RecyclerView container so thy should be right below the Toolbar and right above the RecyclerView container.
when scrolling up, the appbar_scrolling_behavior no longer works. The AppBarLayout/Toolbar does not disappear to make more room to show only the RecyclerView Cardviews.
Pic on top shows the previous, correct layout and pic on bottom shows new, messed up layout. Layout code is below the pics.
I did try to constrain the ConstraintLayout top to the bottom of the appbar and then to the bottom of the toolbar and neither worked. I also tried to constrain the height of the ConstraintLayout to "wrap_content" and that resulted in a blank RecyclerView list that showed no CardViews.
I also tried to replace the "implementation 'androidx.core:core:1.12.0'" with version "...1.13.0-alpha01'" to see if that version included a code update for the problem, but no luck.
Any ideas on how to fix?
The MainActivity layout file is activity_main.xml:
<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:background="#FFFFFF"
android:paddingBottom="6dp"
tools:context=".MainActivity" >
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/action_logo"
android:title="@string/action_logo"
android:contentDescription="@string/action_logo"
android:src="@drawable/ic_toolbar_logo_foreground"
android:background="#FFFFFF"
android:gravity="start"
android:clickable="true"
android:focusable="true"
app:showAsAction="always" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/filterListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="4dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/filter"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/text_primary"
android:textStyle="italic"
app:drawableLeftCompat="@drawable/ic_filter_list_white_24dp"
app:drawableStartCompat="@drawable/ic_filter_list_white_24dp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/quickListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/quicklist"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/text_primary"
android:textStyle="bold"
android:tooltipText="sort quicklist by default"
tools:targetApi="o" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/sortListTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="14dp"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/sort"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/text_primary"
android:textStyle="italic"
app:drawableEndCompat="@drawable/ic_sort_white_24dp"
app:drawableRightCompat="@drawable/ic_sort_white_24dp" />
<!-- Added an empty view which will be shown when the EmptyRecyclerView
is empty -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvQuickcards"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_todo" />
<ViewStub
android:id="@+id/onboardingViewStub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout="@layout/custom_stub2" />
<ViewStub
android:id="@+id/taptheplusStub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout="@layout/custom_stub3" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/button_add_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_add"
android:contentDescription="@string/newcardbutton" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

