allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.oneAcorn:FoldNavScrollLayout:1.1'
}
<?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>
<?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
增加折叠与展开的监听,使用方法:
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();
}
});