A view that was inspired by Google's Play Kiosk.
The header automatically sets itself up with the help of an ViewPager
.
Provided a fully working sample.
##Installation
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add the dependency
dependencies {
compile 'com.github.timrijckaert:NewsStandHeaderView:v1.4'
}
##Usage :
Add the NewsStandHeaderView
in your CollapsingToolbarLayout
or AppBarLayout
.
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.design.widget.CollapsingToolbarLayout>
<be.vrt.mobile.android.sporza.voetbal.ui.widget.slf.NewsStandHeaderView
android:id="@+id/newsstandheaderview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar/>
<android.support.design.widget.TabLayout />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager />
</android.support.design.widget.CoordinatorLayout>
add the attached ViewPager
.
You can call setupWithViewPager
similar to TabLayout
's setupWithViewPager
@Bind(R.id.tablayout)
TabLayout tabLayout;
@Bind(R.id.viewpager)
ViewPager viewPager;
@Bind(R.id.newsstandheaderview)
NewsStandHeaderView newsStandHeaderView;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
tabLayout.setupWithViewPager(viewPager);
newsStandHeaderView.setupWithViewPager(viewPager);
}
your ViewPager
's adapter will need to implement NewsStandHeaderView.NewsStandHeaderViewConfiguratorAdapter
to provide the correct colors and fallback images.
You can push images to the header with setImages(int position of tab where the images should be displayed, List<String>)
.
newsStandHeaderView.setImages(0, asList(
"http://sporza.be/polopoly_fs/1.2648002!image/4084014349.jpg_gen/derivatives/landscape670/4084014349.jpg",
"http://sporza.be//polopoly_fs/1.2648048!image/755200629.jpg_gen/derivatives/landscape670/755200629.jpg",
"http://sporza.be/polopoly_fs/1.2647785!image/1278319731.jpg_gen/derivatives/landscape670/1278319731.jpg"
));
- Sporza Voetbal (from VRT)
- Picasso (from Square)
- KenBurnsView (from flavioarfaria)
- Special thanks to Filip Maelbrancke (filipmaelbrancke)