Android 工具栏没有';滚动时不要隐藏
试图使用appbar_scrolling_view_behavior+scroll标志隐藏listview scroll上的工具栏,但没有结果,这是xml代码,无法理解这有什么问题Android 工具栏没有';滚动时不要隐藏,android,xml,Android,Xml,试图使用appbar_scrolling_view_behavior+scroll标志隐藏listview scroll上的工具栏,但没有结果,这是xml代码,无法理解这有什么问题 <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.lol.materialdesigntest.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/holo_orange_light"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/list_view"
app:layout_anchorGravity="bottom|right"
android:src="@mipmap/ic_launcher"
android:layout_margin="15dp"/>
</android.support.design.widget.CoordinatorLayout>
默认情况下,ListView没有启用嵌套的滚动条。使用
ViewCompat.setNestedScrollingEnabled(listView, true);
要启用它
请注意,这将从棒棒糖开始。如果你想支持旧版本的android,你应该使用RecyclerView,它不支持嵌套滚动
使用
RecyclerView
而不是ListView
,并在RecyclerView中启用嵌套滚动。最佳做法是将RecyclerView
与app:layou\u behavior=“@string/appbar\u scrolling\u view\u behavior”一起使用
内部CoordinatorLayout
代码看起来不错..您正在测试什么操作系统版本?这可能会对您有所帮助!请注意,这将从棒棒糖开始。如果你想支持旧版本的android,你应该使用RV