如何替换旧 API<21 中的 NestedScrollView?
How to replace NestedScrollView in older API<21?
我的布局片段有问题:
<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>
当用户滚动片段时,我需要 disappear/appear 工具栏。
此方法不适用于 API 19(例如):您将如何使用此 Android 设备?
您需要使用 CoordinatorLayout。从 CodePath
查看本指南
https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
这在 API 21 下的 XML 中不起作用,但相应的代码在支持库中可以正常工作:
recyclerView.setNestedScrollingEnabled(true);
我的布局片段有问题:
<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>
当用户滚动片段时,我需要 disappear/appear 工具栏。 此方法不适用于 API 19(例如):您将如何使用此 Android 设备?
您需要使用 CoordinatorLayout。从 CodePath
查看本指南https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout
这在 API 21 下的 XML 中不起作用,但相应的代码在支持库中可以正常工作:
recyclerView.setNestedScrollingEnabled(true);