【问题标题】:app bar not hiding when scrolling in android在android中滚动时应用栏不隐藏
【发布时间】:2015-07-25 04:56:22
【问题描述】:

嘿伙计们,我想弄清楚如何在向下滚动时隐藏应用栏并在向上滚动时显示它。不幸的是,我的 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')
}

【问题讨论】:

    标签: android androiddesignsupport


    【解决方案1】:

    ScrollView 替换为 android.support.v4.widget.NestedScrollView - 只有 NestedScrollView 提供了在 Lollipop 之前隐藏应用栏所需的滚动回调。

    【讨论】:

    • 我假设您的NestedScrollView 中实际上有超过屏幕的内容?除非有要滚动的内容,否则它不会滚动。
    • 是的,我确实有一些东西要滚动。你检查过我的馅饼吗?上面没有内容,因为我动态创建内容,这就是我将其留空的原因
    • 你能更新到版本 22.2.1 看看是否有什么不同吗?围绕动态内容修复了许多错误。
    • 我刚刚完成更新,但仍然没有运气。依赖项 { 编译 fileTree(dir: 'libs', include: ['.jar']) 编译 'com.android.support:appcompat-v7:22.2.1' 编译 'com.android.support:design:22.2 .1' compile 'com.parse.bolts:bolts-android:1.+' compile fileTree(dir: 'libs', include: 'Parse-.jar') }
    • 我已经在这里找到了答案:stackoverflow.com/questions/31007652/…“似乎由于某种原因,使用 标记时使用 CoordinatorLayout 滚动不起作用。”并且有人已经发送了问题:code.google.com/p/android/issues/detail?id=175526
    【解决方案2】:

    我找到了为什么它不起作用的答案。 CoordinatorLayout does not hide Toolbar on scrolling despite implementing all required parameters “似乎由于某种原因,使用标签时使用 CoordinatorLayout 滚动不起作用。” 并且有人已经发送了问题:https://code.google.com/p/android/issues/detail?id=175526

    【讨论】:

      猜你喜欢
      • 2019-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-29
      • 2017-03-03
      • 1970-01-01
      相关资源
      最近更新 更多