Giter Site home page Giter Site logo

foldnavscrolllayout's Introduction

FoldNavScrollLayout

使用NestedScrollingParent实现的导航栏滑动折叠效果的ViewGroup

github

一 引用方法

1.在root build.gradle中加入
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
2.在项目的 build.gradle中加入
dependencies {
	        implementation 'com.github.oneAcorn:FoldNavScrollLayout:1.1'
	}

二 使用方法

1.在xml中声明(FoldNavScrollLayout内的View只是示例,只要id是对的就行)
<?xml version="1.0" encoding="utf-8"?>
<com.acorn.library.FoldNavScrollLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <RelativeLayout
        android:id="@id/fold_nav_layout"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#ffffff"/>

    <android.support.design.widget.TabLayout
        android:id="@id/fold_tab_layout"
        android:layout_width="match_parent"
        android:layout_height="34dp"
        />

    <android.support.v4.view.ViewPager
        android:id="@id/fold_content_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
</com.acorn.library.FoldNavScrollLayout>

请注意,FoldNavScrollLayout内第一层childView需要至少有3个如下id的View存在

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="fold_nav_layout" type="id"/>
    <item name="fold_tab_layout" type="id"/>
    <item name="fold_content_layout" type="id"/>
</resources>

作用分别是 fold_nav_layout 导航栏,拖动时根据方向显示/隐藏 fold_tab_layout 位置固定的View,不一定是TabLayout fold_content_layout 可竖向滑动的View

2.完成,就当它是个LinearLayout,该怎么用就怎么用

版本更新

1.1

增加折叠与展开的监听,使用方法:

foldNavScrollLayout.setOnFoldNavListener(new IFoldNavListener() {
          @Override
          public void onNavFoldBegin() {
              Log.i("navfold","onNavFoldBegin");
              Toast.makeText(MainActivity.this,"onNavFoldBegin",Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onNavFoldFinish() {
              Log.i("navfold","onNavFoldFinish");
              Toast.makeText(MainActivity.this,"onNavFoldFinish",Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onNavExpandBegin() {
              Log.i("navfold","onNavExpandBegin");
              Toast.makeText(MainActivity.this,"onNavExpandBegin",Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onNavExpandFinish() {
              Log.i("navfold","onNavExpandFinish");
              Toast.makeText(MainActivity.this,"onNavExpandFinish",Toast.LENGTH_SHORT).show();
          }
      });

foldnavscrolllayout's People

Contributors

oneacorn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

foldnavscrolllayout's Issues

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.