try to fix SearchBar disappearing

This commit is contained in:
Daniel Gultsch 2023-02-20 16:49:33 +01:00
parent fe9b3b8ed9
commit b80fe9802a
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2

View file

@ -16,7 +16,8 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/searchbar_scrolling_view_behavior"/> android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout" android:id="@+id/app_bar_layout"
@ -24,12 +25,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:elevation="0dp" app:elevation="0dp"
app:liftOnScroll="false"> app:liftOnScroll="false">
<!-- app:layout_scrollFlags="scroll|enterAlways" provides 'gmail like' effect for
when the nestedscrollview actually has something to scroll. However this seems buggy
when there is nothing to scroll as you can move the searchbar out of the view.
'snap' doesnt seem to have the bug but the the Searchbar always stays visible.
A possible work around would be to toggle between scroll|EnterAlways and snap
depending on how many items are in the view. -->
<com.google.android.material.search.SearchBar <com.google.android.material.search.SearchBar
android:id="@+id/search_bar" android:id="@+id/search_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/search_in_chats" android:hint="@string/search_in_chats"
app:navigationIcon="@drawable/ic_menu_24dp"/> app:layout_scrollFlags="snap"
app:navigationIcon="@drawable/ic_menu_24dp" />
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
@ -38,10 +46,10 @@
android:id="@+id/extended_fab" android:id="@+id/extended_fab"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="@string/start_chat" android:text="@string/start_chat"
app:icon="@drawable/ic_chat_24dp"/> app:icon="@drawable/ic_chat_24dp" />
<com.google.android.material.search.SearchView <com.google.android.material.search.SearchView
android:id="@+id/search_view" android:id="@+id/search_view"
@ -63,8 +71,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="start" android:layout_gravity="start"
app:menu="@menu/fragment_overview" app:headerLayout="@layout/item_navigation_header"
app:headerLayout="@layout/item_navigation_header"/> app:menu="@menu/fragment_overview" />
</androidx.drawerlayout.widget.DrawerLayout> </androidx.drawerlayout.widget.DrawerLayout>
</layout> </layout>