Coder Social home page Coder Social logo

iq-scm / stickyheaderviewpager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from w446108264/stickyheaderviewpager

0.0 0.0 0.0 26.8 MB

An Android library supports sticking the navigator on the top when ItemView scrolls in Viewpager.

License: Apache License 2.0

Java 100.00%

stickyheaderviewpager's Introduction

StickyHeaderViewPager

j.s ๐Ÿ‡จ๐Ÿ‡ณ

Stop Support

recommend the new project ใ€Œ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 ใ€

Art

Art

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

Usage

Layout

howerver, StickHeaderViewPager must have two childViews,frist childView will scroll with viewpager,second will tick on the top.

  <com.library.StickHeaderViewPager
        android:id="@+id/shvp_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/toolbar">
        
        <ImageView
            android:id="@+id/iv_headerImage"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:src="@drawable/bg_simple_header"
            android:scaleType="centerInside"/>

        <TextView
            android:id="@+id/tv_stick"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:gravity="center_vertical"
            android:paddingLeft="10dp"
            android:background="#657232"
            android:text="This is a simple demo!"
            />  
 </com.library.StickHeaderViewPager>

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.

  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<String> 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.

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.

Thanks

  • ParallaxHeaderViewPager

stickyheaderviewpager's People

Contributors

w446108264 avatar

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.