https://github.com/dmfs/drawablepagertitlestrip
A PagerTitleStrip for Images
https://github.com/dmfs/drawablepagertitlestrip
Last synced: 19 days ago
JSON representation
A PagerTitleStrip for Images
- Host: GitHub
- URL: https://github.com/dmfs/drawablepagertitlestrip
- Owner: dmfs
- Created: 2014-04-05T19:02:25.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-19T19:44:19.000Z (over 10 years ago)
- Last Synced: 2023-03-23T03:56:27.560Z (over 3 years ago)
- Language: Java
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DrawablePagerTitleStrip
__A PagerTitleStrip for Images__
This is a version of a PagerTitleStrip that shows images instead of text. See [color-picker](https://github.com/dmfs/color-picker) for screenshots and an implementation example.
## Requirements
* Android support library 19 or newer
## Example code
The `ViewPager` in this library is just a copy of the original `ViewPager` from the support library, but since the pager title strip classes depend on a
few non-public members you'll we had to include it. That means you'll need to use the `ViewPager` provided by this library.
In your layout file replace `android.support.v4.view.ViewPager` by `org.dmfs.android.view.ViewPager` and `android.support.v4.view.PagerTitleStrip` by `org.dmfs.android.view.DrawablePagerTitleStrip` (or `org.dmfs.android.view.DrawablePagerTabStrip`) like so:
Don't forget to update any imports and types.
Now let your `FragmentStatePagerAdapter` or `FragmentPagerAdapter` implement `IDrawableTitlePagerAdapter`
public class PalettesPagerAdapter extends FragmentStatePagerAdapter implements IDrawableTitlePagerAdapter
{
...
@Override
public Drawable getDrawableTitle(int position)
{
// return a drawable for this page
...
return someDrawable;
}
}
Be aware that neither `DrawablePagerTabStrip` nor `DrawablePagerTitleStrip` will cache the `Drawable`s, so you better take care of that yourself. See [PalettesPagerAdapter.java](https://github.com/dmfs/color-picker/blob/master/src/org/dmfs/android/colorpicker/PalettesPagerAdapter.java) for an example.
## TODO
* dynamically determine the number of images in the title strip
* clean up code
## License
Licensed under Apache2
This work is based on the Android Support Library with the following copyright:
Copyright (C) 2012 The Android Open Source Project
Modifications:
Copyright (C) Marten Gajda 2014