# StickyHeaderViewPager
**Repository Path**: wangweijun123/StickyHeaderViewPager
## Basic Information
- **Project Name**: StickyHeaderViewPager
- **Description**: An Android library supports sticking the navigator on the top when ItemView scrolls in Viewpager.
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-08-14
- **Last Updated**: 2021-08-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
StickyHeaderViewPager
======================
> j.s 🇨🇳
>
> Stop Support
>
> recommend the new project 「[w446108264/ScrollableLayout](https://github.com/w446108264/ScrollableLayout) 」(easy to add a headview for any view and supports sticking the navigator on the top when ItemView scrolls.)
An Android library supports sticking the navigator on the top when ItemView scrolls in Viewpager.
other library which more freely defined 「 [w446108264/StickHeaderLayout](https://github.com/w446108264/StickHeaderLayout) 」


# Features
* Support RecyclerView, ScrollView, WebView, ListView.
* Scrolling, with smooth scrolling fling, will not be interrupt when ticking the navigator.
* Don't need to preset the height value,all is automatic.
# Samples
You can [download a sample APK](https://github.com/w446108264/StickyHeaderViewPager/raw/master/output/simple.apk)
# Usage
### Layout
howerver, `StickHeaderViewPager` must have two childViews,frist childView will scroll with viewpager,second will tick on the top.
```xml
```
### Fragment
and then create a fragment which extends `ScrollFragment`.it's easy. if you need a ListView ,please make your fragment extends StickHeaderListFragment,if you want to create a webView ,just extends StickHeaderWebViewFragment. even dot't need to inflate view by yourself. for a example.
```java
public class ListViewSimpleFragment extends StickHeaderListFragment {
public static ListViewSimpleFragment newInstance() {
ListViewSimpleFragment fragment = new ListViewSimpleFragment();
return fragment;
}
public static ListViewSimpleFragment newInstance(String title) {
ListViewSimpleFragment fragment = new ListViewSimpleFragment();
fragment.setTitle(title);
return fragment;
}
@Override
public void bindData() {
setAdapter();
}
public void setAdapter() {
if (getActivity() == null) return;
int size = 100;
String[] stringArray = new String[size];
for (int i = 0; i < size; ++i) {
stringArray[i] = ""+i;
}
ArrayAdapter adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, stringArray);
getScrollView().setAdapter(adapter);
}
}
```
### Activity
last step,init your StickHeaderViewPager with `StickHeaderViewPagerBuilder`.that's all. by the way,activity should extends FragmentActivity or AppCompatActivity.
```java
StickHeaderViewPagerBuilder.stickTo((StickHeaderViewPager) findViewById(R.id.shvp_content))
.setFragmentManager(getSupportFragmentManager())
.addScrollFragments(ListViewSimpleFragment.newInstance("ListView"))
.notifyData();
```
# Contact & Help
Please fell free to contact me if there is any problem when using the library.
* email: shengjun8486@gmail.com
# Thanks
* ParallaxHeaderViewPager