Coder Social home page Coder Social logo

fcnestedscrollview's Introduction

FCNestedScrollView

主要是用来解决滚动嵌套问题,比如NestedScrollView 嵌套 RecyclerView,看了网上很多别人实现的代码,大部分都是让RecyclerView的高度等于所有item高度的总和;如果item比较少,可以这样实现,但是如果item比较多,并且可以一直上拉加载更多,这样的话就会导致界面严重卡顿,存在性能问题,因为没有用到recyclerview的缓存机制

而此项目的实现是被嵌套的RecyclerView定高,然后手动解决手势冲突问题,这样的话即使item再多也不存在性能问题

滚动   fling

下拉刷新 常用需求

maven地址

maven { url 'https://jitpack.io' }

gradle依赖

implementation 'com.github.403462630:FCNestedScrollView:1.0.0'

此项目提供四个view

  • FCNestedScrollView
  • FCRecyclerView
  • FCWebView
  • FCSwipeRefreshLayout

注意

  • 支持FCNestedScrollView 嵌套 FCNestedScrollView、FCRecyclerView、FCWebView
  • 支持嵌套下拉刷新(目前只扩展了系统自带的SwipeRefreshLayout, 如果只是在最外层的滚动视图添加下拉刷新,则无任何限制)
  • FCNestedScrollView支持多层嵌套(最少支持三层嵌套,更多层嵌套没测试过,按道理应该也可以)
  • 不支持FCRecyclerView 嵌套FCNestedScrollView、FCWebView(基本上没这种需求)

三种可嵌套滚动view用法如下

自定义属性

fc_scroll_mode如下:
  • none parentview优先滚动,然后自己消费
  • all (默认)自己优先滚动,然后parentview消费
  • up 自己优先向上滚,然后parentview消费
  • down 自己优先向下滚,然后parentview消费
fc_is_linked_parent如下:
  • true (默认)fling时,当自己滚动完成之后 传递给parentview继续fling
  • false fling时,当自己滚动完成之后 不传递给parentview继续fling
fc_is_linked_child 如下:
  • true (默认)当自己滚到到顶部或底部的时候,联动childview继续fling
  • false 当自己滚到到顶部或底部的时候,不联动childview继续fling
fc_is_nested_scroll_enabled(目前只有FCWebView支持,因为webview里的内容复杂、不可控,导致可能存在兼容性,建议 如果webview没有嵌套在其它可滚动视图里面,建议设置成false(或者使用原生的webview),否则设置成true)
  • true (默认)
  • false 不会添加任何手势处理,全使用系统默认的手势
fc_is_pull_refresh_intercept(仅FCSwipeRefreshLayout支持)
  • true 下拉时,优先处理下拉刷新
  • false (默认)下拉时,最后处理下拉刷新

Example

<com.fc.nestedscrollview.FCNestedScrollView 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:id="@+id/nested_scroll_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <!-- some view -->
		......


		<!--
			1. 要么在xml里定高
			2. 要么在代码中定高
			fc_scroll_mode 是配置 滚动模式,具体参数的值参考 wiki
		 -->
		<com.fc.nestedscrollview.FCRecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="150dp"
            android:layout_height="200dp"
            app:fc_scroll_mode="all" />

    </LinearLayout>
</com.fc.nestedscrollview.FCNestedScrollView>

混淆

# support package
-keep class android.support.v7.widget.RecyclerView{*;}
-keep class android.support.v4.widget.NestedScrollView{*;}

# androidx package
-keep class androidx.recyclerview.widget.RecyclerView{*;}
-keep class androidx.core.widget.NestedScrollView{*;}

fcnestedscrollview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fcnestedscrollview's Issues

ItemTouchHelper with RecyclerView in NestedScrollView: Drag scrolling not work

All works fine if the RecyclerView is a child of the CoordinatorLayout.

But if the RecyclerView is a child of NestedScrollView in CoordinatorLayout, the drag scrolling not working anymore. Draging an item and move it to the top or bottom of the screen, the RecyclerView not scrolling like it do if its not a child of NestedScrollView.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.