①NestedScrollView与RecyclerView嵌套,导致滚动惯性消失

解决:mRecyclerView.setNestedScrollingEnabled(false);

②NestedScrollView中嵌套其他布局和RecyclerView后,不会滚动到屏幕顶部

解决给最顶部的布局View设置下requestFocus();

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. xmlns:app="http://schemas.android.com/apk/res-auto"
  5. xmlns:tools="http://schemas.android.com/tools"
  6. android:layout_width="match_parent"
  7. android:layout_height="match_parent"
  8. android:background="@android:color/white"
  9. android:orientation="vertical">
  10.  
  11. <android.support.v4.widget.SwipeRefreshLayout
  12. android:id="@+id/swipe"
  13. android:layout_width="match_parent"
  14. android:layout_height="match_parent">
  15.  
  16. <android.support.v4.widget.NestedScrollView
  17. android:id="@+id/src"
  18. android:layout_width="match_parent"
  19. android:layout_height="match_parent"
  20. android:focusable="true"
  21. android:focusableInTouchMode="true">
  22.  
  23. <LinearLayout
  24. android:id="@+id/ll_valuation_start"
  25. android:layout_width="match_parent"
  26. android:layout_height="match_parent"
  27. android:orientation="vertical">
  28.  
  29. <ImageView
  30. android:layout_width="wrap_content"
  31. android:layout_height="wrap_content"
  32. android:layout_marginTop="20dp"
  33. android:src="@drawable/ic_launcher_background"/>
  34.  
  35. <TextView
  36. android:layout_width="wrap_content"
  37. android:layout_height="wrap_content"
  38. android:text="信用可也换钱花"
  39. android:textColor="@android:color/black"
  40. android:textSize="16sp"/>
  41.  
  42. <TextView
  43. android:layout_width="wrap_content"
  44. android:layout_height="wrap_content"
  45. android:padding="6dp"
  46. android:text="自营贷款产品,无需审核,立即放款"
  47. android:textColor="@android:color/black"/>
  48.  
  49. <android.support.v7.widget.RecyclerView
  50.  
  51. android:id="@+id/rv"
  52. android:layout_width="match_parent"
  53. android:layout_height="wrap_content"
  54. >
  55. </android.support.v7.widget.RecyclerView>
  56.  
  57. </LinearLayout>
  58.  
  59. </android.support.v4.widget.NestedScrollView>
  60. </android.support.v4.widget.SwipeRefreshLayout>
  61. </LinearLayout>

如果里面ScrollView里面有连个RecyclerView则都要是设置 mRecyclerView.setNestedScrollingEnabled(false);

Android NestedScrollView与RecyclerView嵌套,以及NestedScrollView不会滚动到屏幕顶部解决的更多相关文章

  1. 使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种滑动冲突

    使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种冲突 如果你还在为处理滑动冲突而发愁,那么你需要静 ...

  2. Android 使用NestedScrollView+ViewPager+RecyclerView+SmartRefreshLayout打造酷炫下拉视差效果并解决各种滑动冲突

    如果你还在为处理滑动冲突而发愁,那么你需要静下心来看看这边文章,如果你能彻底理解这篇文章中使用的技术,那么,一切滑动冲突的问题解决起来就轻而易举了: 先扔一个最终实现的效果图 先分析下效果图中实现的功 ...

  3. Android 6.0+ RecyclerView嵌套在ScrollView中显示不全

    ScrollView嵌套RecyclerView在Android6.0以下能正常显示,但是在6.0以上就会出现RecyclerView显示不全的bug.尝试多种方法之后终于找到解决办法,特在此记录下. ...

  4. NestedScrollView和RecyclerView使用,并设置间距

    NestedScrollView和RecyclerView使用,并设置间距: 效果图如下: 1.NestedScrollView 和RecyclerView嵌套问题(类似ScrollView 和lis ...

  5. Android RecyclerView嵌套RecyclerView

    原理 RecyclerView嵌套RecyclerView的条目,项目中可能会经常有这样的需求,但是我们将子条目设置为RecyclerView之后,却显示不出来.自己试了很久,终于找到了原因:必须先设 ...

  6. Android Fragment使用(二) 嵌套Fragments (Nested Fragments) 的使用及常见错误

    嵌套Fragment的使用及常见错误 嵌套Fragments (Nested Fragments), 是在Fragment内部又添加Fragment. 使用时, 主要要依靠宿主Fragment的 ge ...

  7. RecyclerView嵌套ScrollView导致RecyclerView内容显示不全

    我们在使用RecyclerView嵌套至ScrollView内的时候 RecyclerView不在屏幕内的数据会不显示出来,这里是一个坑,我们需要重写RecyclerView /** * Create ...

  8. Android开发:ScrollView嵌套GridView的解决办法

    Android开发:ScrollView嵌套GridView的解决办法   前些日子在开发中用到了需要ScrollView嵌套GridView的情况,由于这两款控件都自带滚动条,当他们碰到一起的时候便 ...

  9. Android 高级编程 RecyclerView 控件的使用

    RecyclerView 是Android 新添加的一个用来取代ListView的控件,它的灵活性与可替代性比listview更好. 看一下继承关系: ava.lang.Object    ↳ and ...

随机推荐

  1. JS 只创建一个元素

    //判断有没有这个元素<div id="div"> if(my$("div").firstElementChild){ console.log(&q ...

  2. python 安装 wxPtyhon (window)

    检查是否安装pip 打开cmd(全局安装的python)测试是否安装了pip 工具 以上是安装了pip , 执行下载并安装 wxPtyhon 第一种方法: 也可以使用其他的地址 官网地址 https: ...

  3. C++_基础2-复合数据类型

    C语言使用术语“派生类型”,C++对类关系使用术语“派生”.所以就改用“复合类型”. 数组 数组是一种数据格式,能够存储多个同类型的值. 数组声明应指出以下三点: 存储在每个元素中的值的类型: 数组名 ...

  4. LeetCode15. 三数之和

    15. 三数之和 描述 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组. 注意:答案中 ...

  5. 洛谷 [TJOI2010]中位数

    题目链接 题解 比较水.. 常见套路,维护两个堆 Code #include<bits/stdc++.h> #define LL long long #define RG register ...

  6. window7下karma 报 The header content contains invalid characters BUG

    打开你的依赖node_modules\karma\node_modules\connect\lib\patch.js 将里面的setHeader方法改成下面这样,干掉序列化日期时出现的中文 res.s ...

  7. [原创]Aop之使用Autofac+Castle 自动注入服务且动态代理服务实现拦截(非MVC控制器拦截)

    public static class AutofacComponentManualRegister { /// <summary> /// 注册 /// </summary> ...

  8. [转] 使用 Java8 Optional 的正确姿势

    [From] https://unmi.cc/proper-ways-of-using-java8-optional/ 我们知道 Java 8 增加了一些很有用的 API, 其中一个就是 Option ...

  9. Linux——文件和文件夹的操作

    Linux有三种文件: 普通文件(包括文本文件.源码文件.可执行文件等等) 设备文件(或者成为特殊文件,linux通过设备文件与外部设备进行通讯,例如:光驱.打印机.终端.modern) 设备文件有两 ...

  10. 学习javscript函数笔记(二)

    定义: 函数包含一组语句,他们是JavaScript的基础模块单元,用于代码复用.信息隐藏和组合调用.函数用于指定对象的行为. 1.函数对象 JavaScript中的函数就是对象,函数对象连接到Fun ...