android - 在android中滚动时应用栏不隐藏

标签 android androiddesignsupport

大家好,我想弄清楚如何在向下滚动时隐藏应用栏并在向上滚动时显示它。不幸的是我的 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/

相关文章:

java - 将播放服务更新到 8.3.0 后无法创建发布版本

android - 警报对话框生成器确认按钮

android - 内容丰富的 CMS 中的用户身份验证

android - 使用 android.support.v7.widget.ContentFrameLayout.setDecorPadding 在某些设备上应用程序崩溃

android - 错误 : Failed to resolve: androidx. 生命周期 :lifecycle:2. 2.0-beta01

android - 正确创建与 dpad 兼容的 UI

c# - 如何判断 BottomSheetDialogFragment 何时展开以填充屏幕?

Android设计库FAB无阴影

android - 如何在设计支持库的 TabLayout 中设置 Tab 之间的分隔符?

java - 动画:如何使动画在我访问另一个 Activity 并返回后重复播放?