AppBarLayout + NestedScrollView + RecyclerView不会滚动

2024-04-13

您好,我对 google support appbarLayout 有疑问 我的布局结构如下:

问题是,一旦嵌套滚动视图滚动到顶部,我的回收器视图就不会滚动。

我尝试了几乎所有解决方案,但似乎没有任何效果。

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_gradient_blue"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/nested_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:nestedScrollingEnabled="false"
        android:padding="8dip">
    </android.support.v7.widget.RecyclerView>

</android.support.v4.widget.NestedScrollView>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    style="@style/AppTheme.Toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/background_gradient_blue"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginBottom="250dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            style="@style/AppTheme.Toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@android:color/transparent"
            app:contentInsetStart="72dp"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

在nestedScrollView标签内添加此行

android:focusableInTouchMode="true"

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AppBarLayout + NestedScrollView + RecyclerView不会滚动 的相关文章

  • 使用 GoogleServices 插件时忽略 Gradle ArchivesBaseName

    我经常使用 archivesbasename 来重命名我的输出 apk 但自从使用 google services 插件后 它就被忽略了 我能做些什么来让它再次工作吗 下面附上了我完整的 build gradle 感谢您的指点 apply
  • startActivity overridePendingTransition 只显示进入动画

    基本上 我遇到的问题是只显示输入幻灯片动画 调用 Activity 不会产生动画 startActivity intent overridePendingTransition R anim right in partly R anim le
  • Android自定义控件命名空间问题

    我一直在为 Android 开发自定义控件 尽管我尝试按照建议进行操作here https stackoverflow com questions 4495511 how to pass custom component parameter
  • 添加动态数据时 footable 出现问题

    我需要 jQuery Mobile 方面的一些帮助富表 http css tricks com footable a jquery plugin for responsive data tables 我正在表中动态添加数据 HTML tab
  • 毕加索磁盘缓存

    我正在使用 Picasso 从 URL 加载图像 Picasso with getApplicationContext load product getImageUrl into imageView 据我所知 每次都会访问该网址 而不是缓存
  • 维护 HttpUrlConnection 调用之间的会话(Native/Webview)

    让我从我做的开始desire 我想制作一个应用程序part native and part webviews Problem 维护本机和 webview 部分之间的会话 My 处理方法 this 我打算实现一个本机登录 其中我向用户展示两个
  • 游标索引越界异常

    打开后出现光标索引越界错误 数据库 请任何人告诉我如何打开现有数据库 sqllite Android 我想在数据库上触发一个选择查询 检索一些信息 public void getPatient SQLiteDatabase db Strin
  • Android CursorAdapter、ListView 和后台线程

    我一直在开发的这个应用程序有包含数兆字节数据的数据库可供筛选 许多活动只是列表视图 通过数据库中的各个级别的数据下降 直到到达 文档 即从数据库中提取并显示在手机上的 HTML 我遇到的问题是 其中一些活动需要能够通过捕获击键并重新运行带有
  • 在浏览器中打开 URL,即使我的应用程序为其注册了意图过滤器

    我的应用程序为某些 URL 注册了一个意图过滤器 因为它可以处理来自这些 URL 的数据 但是 在应用程序内部 我想提供一个按钮来在浏览器中打开这样的 URL 也就是说 如果设置了默认浏览器 则在默认浏览器中打开它 否则提供一个选择器 就像
  • 我的 Android 设备需要安装哪个驱动程序才能运行我的应用程序?

    我购买了 intex mobile 来在真实设备中测试我的 Android 应用程序 然而 该设备不存在于 OEM USB 驱动程序列表中 android 提供的设备列表中 我检查了 intex 官方网站 但不确定到底需要安装哪个驱动程序
  • 在后台服务中持续获取位置更新

    我正在开发需要在后台服务中持续获取位置更新的应用程序 我已经使用了它正在使用的后台粘性服务 但是 即使我添加了启动广播并在那里启动了服务 启动完成后服务也没有启动 服务启动并立即被杀死 另外 这不适用于奥利奥 服务在应用程序关闭几分钟后停止
  • 更改 Android 中的媒体音量?

    我可以更改媒体音量吗 如何 到目前为止我用过这个 setVolumeControlStream AudioManager STREAM MUSIC 但有一个搜索栏并且想要更改媒体音量 而不是铃声音量 那么有人可以告诉我如何更改媒体音量onC
  • 使用 mupdf android 库导航到特定页面

    我如何使用 muPDF 库导航到特定页面 或者有没有办法让图书馆不记得我最后在那个pdf文件中浏览的是哪一页 Uri uri Uri parse path Intent intent new Intent MainActivity getC
  • Android 消费品:“已经拥有该商品”,但 inventory.hasPurchase() 为 false

    我被 Google In App v3 困住了 我测试了一次没有消费的购买 例如 当应用程序在购买和消费之间崩溃时 现在我找不到出路 如果我尝试再次购买 它会显示 您已经拥有该商品 但是当我测试所有权时 它说我不拥有它 Inventory
  • Android httpclient文件上传数据损坏和超时问题

    我在 Android 中上传图像时遇到问题 我正在使用 apache httpmime 4 1 lib 代码是这样的 MultipartEntity reqEntity new MultipartEntity HttpMultipartMo
  • 如何更改 Android 12 启动屏幕中的图标形状?

    我想要矩形形状的启动屏幕图标 而不是 android 12 中的圆形形状 我不相信你可以 如果你看这里的第 3 点 https developer android com about versions 12 features splash
  • 在 android 中,第一次单击时按钮侦听器未注册

    因为我是 Android 新手 所以我遇到了按钮监听器的问题 我正在使用 OnClickListener 来处理胸像 但它第一次点击后不执行一旦我单击多个 它就会表现良好 但如何使其在第一次单击时成为可能 这是我的代码 public cla
  • BitmapFactory.decodeResource() 忽略 jpg 图像的 inPreferredConfig 选项

    我尝试将jpeg资源图像加载到ARGB 8888格式的位图 BitmapFactory Options opts new BitmapFactory Options opts inPreferredConfig Bitmap Config
  • Application.onLowMemory() 未调用

    我创建了自己的应用程序类 我尝试调试它 代码在 Application onCreate 处停止 但不会在 onLowMemory 处停止 为了测试该场景 我打开了许多其他高内存应用程序 我看到的是调试会话终止 在 Eclipse 中 并且
  • 查询联系人 - 有时返回空游标

    我正在尝试查询联系人的显示名称 Override public void onActivityResult int requestCode int resultCode Intent data switch requestCode case

随机推荐