|
1 | 1 | # FoldNavScrollLayout |
2 | | -###使用NestedScrollingParent实现的导航栏滑动折叠效果的ViewGroup |
| 2 | +### 使用NestedScrollingParent实现的导航栏滑动折叠效果的ViewGroup |
3 | 3 |
|
4 | 4 |  |
5 | 5 |
|
| 6 | +### 一 引用方法 |
| 7 | + |
| 8 | +##### 1.在root build.gradle中加入 |
| 9 | + |
| 10 | +```gradle |
| 11 | +allprojects { |
| 12 | + repositories { |
| 13 | + ... |
| 14 | + maven { url 'https://jitpack.io' } |
| 15 | + } |
| 16 | + } |
| 17 | +``` |
| 18 | + |
| 19 | +##### 2.在项目的 build.gradle中加入 |
| 20 | + |
| 21 | +```gradle |
| 22 | +dependencies { |
| 23 | + implementation 'com.github.oneAcorn:FoldNavScrollLayout:1.0' |
| 24 | + } |
| 25 | +``` |
| 26 | + |
| 27 | +### 二 使用方法 |
| 28 | + |
| 29 | +##### 1.在xml中声明(FoldNavScrollLayout内的View只是示例,只要id是对的就行) |
| 30 | + |
| 31 | +```xml |
| 32 | +<?xml version="1.0" encoding="utf-8"?> |
| 33 | +<com.acorn.library.FoldNavScrollLayout |
| 34 | + xmlns:android="http://schemas.android.com/apk/res/android" |
| 35 | + xmlns:tools="http://schemas.android.com/tools" |
| 36 | + android:layout_width="match_parent" |
| 37 | + android:layout_height="match_parent" |
| 38 | + tools:context=".MainActivity"> |
| 39 | + |
| 40 | + <RelativeLayout |
| 41 | + android:id="@id/fold_nav_layout" |
| 42 | + android:layout_width="match_parent" |
| 43 | + android:layout_height="48dp" |
| 44 | + android:background="#ffffff"/> |
| 45 | + |
| 46 | + <android.support.design.widget.TabLayout |
| 47 | + android:id="@id/fold_tab_layout" |
| 48 | + android:layout_width="match_parent" |
| 49 | + android:layout_height="34dp" |
| 50 | + /> |
| 51 | + |
| 52 | + <android.support.v4.view.ViewPager |
| 53 | + android:id="@id/fold_content_layout" |
| 54 | + android:layout_width="match_parent" |
| 55 | + android:layout_height="match_parent" |
| 56 | + /> |
| 57 | +</com.acorn.library.FoldNavScrollLayout> |
| 58 | +``` |
| 59 | +### 请注意,FoldNavScrollLayout内第一层childView需要至少有3个如下id的View存在 |
| 60 | +```xml |
| 61 | +<?xml version="1.0" encoding="utf-8"?> |
| 62 | +<resources> |
| 63 | + <item name="fold_nav_layout" type="id"/> |
| 64 | + <item name="fold_tab_layout" type="id"/> |
| 65 | + <item name="fold_content_layout" type="id"/> |
| 66 | +</resources> |
| 67 | +``` |
| 68 | +作用分别是 |
| 69 | +fold_nav_layout 导航栏,拖动时根据方向显示/隐藏 |
| 70 | +fold_tab_layout 位置固定的View,不一定是TabLayout |
| 71 | +fold_content_layout 可竖向滑动的View |
| 72 | + |
| 73 | +##### 2.完成,就当它是个LinearLayout,该怎么用就怎么用 |
0 commit comments