Switch to ViewPager2 was successful; it was essentially a drop-in replacement. There's a bug in the connected TabLayout where, if the app starts and scrolls programmatically to Wednesday or later, the tab won't be focussed until the user starts scrolling again

This commit is contained in:
denizk0461
2023-04-12 16:46:38 +02:00
parent 8b690a4593
commit 4f78eb8373
5 changed files with 41 additions and 90 deletions
+7 -35
View File
@@ -7,52 +7,24 @@
tools:context=".fragment.EventFragment">
<com.google.android.material.tabs.TabLayout
android:id="@+id/day_tabs"
android:id="@+id/day_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
app:layout_constraintEnd_toEndOf="parent"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/monday"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tuesday"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wednesday"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/thursday"/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/friday"/>
</com.google.android.material.tabs.TabLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/view_pager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/day_tabs"
app:layout_constraintBottom_toBottomOf="parent"
android:scrollbars="horizontal"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
app:layout_constraintTop_toBottomOf="@+id/day_tab_layout"
app:layout_constraintBottom_toBottomOf="parent"/>
<!-- app:layout_behavior="@string/appbar_scrolling_view_behavior"-->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"