我的布局 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>
当用户滚动 fragment 时,我需要消失/出现工具栏。 此方法不适用于 API 19(例如):你会用这个 Android 设备做什么?
最佳答案
这在 API 21 下的 XML 中不起作用,但相应的代码在支持库中可以正常工作:
recyclerView.setNestedScrollingEnabled(true);
关于android - 如何替换旧 API<21 中的 NestedScrollView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39837499/