如何在旧版API <21中替换NestedScrollView?

Hel*_*pme 4 android android-layout android-fragments android-toolbar

我有一个布局片段的问题:

<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>
Run Code Online (Sandbox Code Playgroud)

当用户滚动片段时,我需要消失/出现工具栏.此方法不适用于API 19(例如):您将如何使用此Android设备?

Her*_*t74 8

这在API 21下的XML中不起作用,但相应的代码在支持库中工作:

recyclerView.setNestedScrollingEnabled(true);
Run Code Online (Sandbox Code Playgroud)