StickyNavLayout 悬浮控件
该项目是在一个开源项目的基础上修改的
原项目地址:https://github.com/hongyangAndroid/Android-StickyNavLayout
修改如下:
1.在原基础上支持对内容listview等控件空布局的滑动支持 2.修改当刚刚悬浮的时候抬起手触发onItemClick事件的bug 3.修改手快速滑动的时候触发onItemClick事件的bug 4.增加一些自定义属性,后文有介绍 5.增加是否处于悬浮的回调接口,和滑动到悬浮状态的比例:0#GridViewWithHeaderAndFooterFragment
地址:https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter
#声明 本项目纯属开源,只是为了更好的提高Android的开发技术,小宝贝们~~~~~
效果图 #自定义属性 ```java ```
#使用时的注意事项 注意控件id的设置
top区域:id必须为: android:id="@id/id_stickynavlayout_topview" 悬浮区域:id必须为: android:id="@+id/id_stickynavlayout_indicator" 内容区域:id必须为: android:id="@id/id_stickynavlayout_viewpager" 内容区域 1.比需为ViewPager或者其子类 2.ViewPager的内容可以是Fragment,如果Fragment想用ListView,RecycleView等需要设置其id为: android:id="@+id/id_stickynavlayout_innerscrollview" 比如:<FrameLayout 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="com.gxz.stickynavlayout.fragments.RecycleViewFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/id_stickynavlayout_innerscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
or
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/id_stickynavlayout_innerscrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/msg"
android:textSize="20sp" />
</ScrollView>
</LinearLayout>
#使用
<com.gxz.library.StickyNavLayout
android:id="@+id/id_stick"
android:layout_width="match_parent"
android:layout_height="match_parent"
stick:isStickNav="true">
<LinearLayout
android:id="@id/id_stickynavlayout_topview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#fee"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="top-view"
android:textAllCaps="true"
android:textSize="30sp" />
</LinearLayout>
<com.gxz.PagerSlidingTabStrip
android:id="@+id/id_stickynavlayout_indicator"
android:layout_width="match_parent"
android:layout_height="48dp"
android:textSize="16sp"
pst:pstsDividerColor="@color/colorPrimary"
pst:pstsIndicatorColor="@color/colorPrimary"
pst:pstsIndicatorHeight="5dp"
pst:pstsScaleZoomMax="0"
pst:pstsShouldExpand="false"
pst:pstsTextSelectedColor="#303F9F"
pst:pstsUnderlineColor="@color/colorPrimary" />
<android.support.v4.view.ViewPager
android:id="@id/id_stickynavlayout_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.gxz.library.StickyNavLayout>
Java 代码使用
相信你可以点一下就知道什么用了 .... 是不是呢?小宝贝~~~!!
#接口回调
stickyNavLayout.setOnStickStateChangeListener(new StickyNavLayout.onStickStateChangeListener() {
@Override
public void isStick(boolean isStick) {
}
@Override
public void scrollPercent(float percent) {
}
});
#Maven
<dependency>
<groupId>com.gxz.pagerslidingtabstrip</groupId>
<artifactId>library</artifactId>
<version>1.1</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
Gradle
compile('com.gxz.stickynavlayout:library:1.0')
#Demo Demo中的导航控件是:PagerSlidingTabStrip
是我一个开源项目: https://github.com/ta893115871/PagerSlidingTabStrip
#感谢 感谢我的同事的帮助
https://github.com/DukeLee1989