4

How can I have fixed tabs with a sliding tab indicator like described here:

How to get this type of TAB hairline movement

http://www.pushing-pixels.org/2013/05/09/android-bits-and-pieces-sliding-tabs-madness.html

& here

http://viewpagerindicator.com/

using as much stock android as possible. But the important part is FIXED, I dont want tabs that looks like they are in a scrollview like all these examples have. And preferably with icons and not text.

Community
  • 1
  • 1
just_user
  • 11,769
  • 19
  • 90
  • 135
  • So you want tabs to be swipe-able? Or just that the transition between them shows them swiping? – nstosic Nov 09 '13 at 16:53
  • I want the indicator, the little line under the title of each tab to slide. Like in all example I posted links to above. Swipe between the tabs them selves should work as well, but I already have that working. – just_user Nov 09 '13 at 16:57
  • Ah, you just want to have the line indicating which tab is currently selected. That is done via `theme` or `style`. Do you use your own theme or a native one? – nstosic Nov 09 '13 at 17:00
  • I have an indicator line already, but I want it to slide when I slide between the tabs. Check the first link above please. Now it just makes a jump for me with no transition. I want the indicator itself to slide. – just_user Nov 09 '13 at 17:04
  • 1
    Now that is a good question ;) – nstosic Nov 09 '13 at 17:10

2 Answers2

0

As for stock android solution, I assume you could use HorizontalScrollView at the top of your container (just below the ActionBar) and use SmoothScrollTo(int x, int y) method with x and y coordinates obtained from your ActionBar. But that's just the beginning, you'd have to do a lot of modification. There's also an Apache 2.0 licensed library @ github that already did all those modifications for you so you might use it instead.

nstosic
  • 2,584
  • 1
  • 17
  • 21
  • Thanks, but this one like the other ones doesn't have fixed tabs. Maybe I have to do it the long way like you described. – just_user Nov 09 '13 at 17:47
  • Perhaps you can extend his library to use with fixed tabs instead of writing it all over again. – nstosic Nov 09 '13 at 17:57
0

Use https://github.com/astuetz/PagerSlidingTabStrip and .setShouldExpand(true)

As long as your tabs would normally fit in the parent width (screen width), then you'll get fixed tabs with an animated tab indicator.

clocksmith
  • 6,226
  • 3
  • 32
  • 45