zoukankan      html  css  js  c++  java
  • 关于含RecyclerView的fragment来回切换时页面自动滑动到底部的解决方法

    原因:

    在fragment中来回切换时RecyclerView获得了焦点,而RecyclerView的 focusableOnTouchMode属性默认是true,所以在切换时RecyclerView自动获得焦点就滚动到了底部。

    解决办法:

    将RecyclerView上面的控件的设置android:focusableInTouchMode="true"(若无上方控件建议加一个不影响布局的View),如:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:orientation="vertical">
     6     <View
     7         android:layout_width="match_parent"
     8         android:layout_height="2px"
     9         android:background="#bfbfbf"
    10         android:focusable="true"
    11         android:focusableInTouchMode="true"/>
    12     <android.support.v7.widget.RecyclerView
    13         android:layout_width="match_parent"
    14         android:layout_height="match_parent"
    15         android:paddingRight="8dp"
    16         android:paddingLeft="8dp"
    17         android:fadingEdge="none">
    18     </android.support.v7.widget.RecyclerView>
    19 </LinearLayout>
  • 相关阅读:
    Redis集群搭建&访问
    Redis集群功能概述
    Redis多机功能之Sentinel
    Redis单机版安装与部署
    Redis多机功能之复制
    Redis多机功能介绍
    Hadoop JobHistory
    Hive基础之COALESCE用法
    junit组合模式应用
    Emmet
  • 原文地址:https://www.cnblogs.com/yang12318/p/9091531.html
Copyright © 2011-2022 走看看