I am using JakeWharton/ViewPagerIndicator and i am trying to get an effect were the current item is fully visible while the next and the previous items are just partially visible. Any ideas of how i go about achieving this.
-
and by "current item" you mean current *page*, not current page *title*? – Bartek Lipinski Aug 31 '15 at 14:24
-
i mean current page. I dont want to have titles – Hopewell Mutanda Aug 31 '15 at 14:45
1 Answers
ViewPagerIndicatorhas nothing to do with this. It just provides with some sort of titles of pages (not necessarily text-based). To make it work you will need to work with theViewPageritself and itsPagerAdapter.You need to override
getPageWidthmethod of yourPagerAdapterand make it return a float value<1.0ffor pages (positions) that you don't want to fit the whole width of the screen. If you want the same behaviour for all pages of yourViewPager, just makegetPageWidthreturn a fixed value<1.0f. So for example it could've looked like that:@Override public float getPageWidth(int position) { return 0.75f; }The previous step will result in something like this:
And I assume your goal looks more like this:
And it's not really that easy to transition between those two ways of displaying pages by a ViewPager (it does not provide with any default way to change gravity of pages or something). And to make your ViewPager display those pages in the center of the View you will need to struggle a bit. There are few threads on SO about that. Ones that I think might help you are this and this. Apart from that you can use this approach.
- 1
- 1
- 30,698
- 10
- 94
- 132

