大家好,我想弄清楚如何在向下滚动时隐藏应用栏并在向上滚动时显示它。不幸的是我的 xml 文件不走运。我看过一些教程并使用了它,但仍然没有运气。我看到一些教程,即使只有 xml 也可以实现,这是我的 xml,希望有人能帮助我弄清楚为什么它不滚动。
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.serverus.oom.ServiceActivity"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include android:id="@+id/app_bar" layout="@layout/app_bar" app:layout_scrollFlags="scroll|enterAlways" />/>
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/service_content"
>
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout >
这是我的 gradle 依赖项。
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}
最佳答案
将 ScrollView
替换为 android.support.v4.widget.NestedScrollView - 只有 NestedScrollView
提供应用栏在 Lollipop 之前隐藏所需的滚动回调。
关于android - 在android中滚动时应用栏不隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31623101/