zoukankan      html  css  js  c++  java
  • Android NestedScrollView与RecyclerView嵌套,以及NestedScrollView不会滚动到屏幕顶部解决

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

    解决:mRecyclerView.setNestedScrollingEnabled(false); 

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

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

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        android:orientation="vertical">
    
        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipe"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <android.support.v4.widget.NestedScrollView
                android:id="@+id/src"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:focusable="true"
                android:focusableInTouchMode="true">
    
    
                <LinearLayout
                    android:id="@+id/ll_valuation_start"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
    
    
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="20dp"
                        android:src="@drawable/ic_launcher_background"/>
    
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="信用可也换钱花"
                        android:textColor="@android:color/black"
                        android:textSize="16sp"/>
    
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="6dp"
                        android:text="自营贷款产品,无需审核,立即放款"
                        android:textColor="@android:color/black"/>
    
                    <android.support.v7.widget.RecyclerView
    
                        android:id="@+id/rv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        >
                    </android.support.v7.widget.RecyclerView>
    
                </LinearLayout>
    
            </android.support.v4.widget.NestedScrollView>
        </android.support.v4.widget.SwipeRefreshLayout>
    </LinearLayout>

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

  • 相关阅读:
    virtual Box在Centos 7上的安装
    Spark MLlib使用有感
    storm集群配置
    eclipse配置hadoop插件
    HDFS的java接口——简化HDFS文件系统操作
    【hbase】——HBase 写优化之 BulkLoad 实现数据快速入库
    【hbase】——Java操作Hbase进行建表、删表以及对数据进行增删改查,条件查询
    【转】RHadoop实践系列之二:RHadoop安装与使用
    【转】RHadoop实践系列之一:Hadoop环境搭建
    Hadoop生态系统如何选择搭建
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/9817231.html
Copyright © 2011-2022 走看看