I have a problem with a layout fragment:
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
android:fillViewport="true"
android:nestedScrollingEnabled="true" <!-- this don't work with api levels older than 21 -->
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<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:orientation="vertical"
tools:context=".MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:id="@+id/elements" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
I need disappear/appear toolbar when the user scroll the fragment. This method don't work with API 19(for example): What would you do with this Android device?
This doesn't work in XML under API 21, but the corresponding code works as it's in the support library:
recyclerView.setNestedScrollingEnabled(true);
You need to use a CoordinatorLayout. Take a look to this guide from CodePath
https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With