PagerTabStrip customization - moving tab background instead of standard indicator - android

I am trying to use PagerTabStrip in my app but need a little customization. My problem is that I want the tab background to be moved instead of the standard indicator. The image should explain it better:
Currently I don't show at all tab indicator, but use a tab background which is a selector (pressed & selected). This tab background behaves like a tab indicator but is jumpy and I would like to move it smoothly when sliding left/right.
I have have used the PagerTabStrip, got it to work and changed the height of the indicator to match the height of the tabbar but this didn't solve the problem because the indicator is drawn on top of the tabs and covers them. To solve the problem the indicator needs to be drawn behind the tabs. To do that I have modified PagerTabStrib and made a custom TabsContainer (by default LinearLayout is used in PagerTabStrip as a tabs container) an inner class which extends LinearLayout and overrides its onDraw() method where I want to draw the moving indicator. This way the indicator should be drawn behind the tabs, right? My problem with the code right now is that I don't get calls to onDraw() inside my custom TabsContainer. What do You think about this solution and about this problem? Do You see any better solution?
Thanks for any help.

Related

Animate Tabs in TabLayout

To be specific I want to animate the tabs and not the ViewPager fragments.
I am having trouble deciding how to build this. Whether to use a separate scrollview or this can be achieved with TabLayout with some customizations.
Goal
Change the size of tab based on selection.
Change the size of tab based on position.
My idea is to use custom tabs & change the size using TabLayout.OnTabSelectedListener methods onTabSelected & onTabUnselected. But I would like to know if there is any direct approach to get this effect. For example, parallax effect in CollapsingToolbar.

How to implement custom tabs titles animation and position

I have seen a great design in one app.
There is custom tabs representation and animation.
If the tabs doesn't has next(the last tab) there are only two tabs on the screen current at the center and adjacent.
And there is custom animation when switchng between tabs.
How to implement similiar tabs view and custom animation.
I will be grateful everyone for help.
You should take a look at this beautiful library: https://github.com/jpardogo/PagerSlidingTabStrip. It's exactly the same what you want I think. If you want to add some beatiful transition animations between the fragments, you can check this: https://github.com/jfeinstein10/JazzyViewPager

How to implement vertically moving tabbs panel?

In google play, if you enter a screen that uses tabs, you can notice how you can scroll each tab but the panel that seen to contain the tabs also moves vertically to a certain extent. I can imagine that it accomplishes the movement of the tab panel with a TranslateAnimation and a layout animations. But what I can't understand is how it decouples the content of the tab from the tab panel.
To answer the decoupling of the tabs and content question; I have implemented this before using 2 sets of tabs. One is in the content as a list header, the other is layered on top of the list in a containing FrameLayout so it's 'floating'.
Using scroll callbacks you can change the visibility of the floating tabs to suit your needs. Once the list header tabs moves off the screen make the floating tabs visible, once they move fully back onto the screen hide the floating tabs.
Just ensure that every time you show/hide tabs that you copy the values for horizontal scroll position and selected tab from the currently visible tabs to the ones that are about to become visible. works a treat.
The best open-source project you can find for this Android-ObservableScrollView

Semitransparent PagerTabStrip with actionbar overlay

I'm using a actionbar with Window.FEATURE_ACTION_BAR_OVERLAY and some transparency. Additionally I'm using a ViewPager with a PagerTabStrip. The problem is the PagerTabStrip is now displayed underneath the actionbar.
Applying a margin to the PagerTabStrip doesn't work at all and applying a margin to the whole ViewPager prevents the content (A ScrollView inside a Fragment) to scroll underneath the actionbar and the PagerTabStrip, which should be semitransparent too.
So currently I'm stucked with
which isn't ideal at all :D
Anyone got an idea to implement this behaviour?
Edit: so the problem consists of 2 parts. Making the content scroll underneath the PagerTabStrip and moving the PagerTitleStrip.
Add a view above the pager tab strip with a height of
?android:attr/actionBarSize
It will take the height of the action bar and "push" the content down.

Make ViewPager overlap PageTitleStrip

I've been struggling with that for a while: Is it possible to force PageTitleStrip draw itself on the content of the ViewPager?
Here is the case:
The red line indicates the end of ViewPager content and the start of PagerTitleStrip. The brown background belongs to the hole activity. Blackboard and blue backgrounds are from fragments in pager. The screen is taken during scrolling so that 2 fragments can be seen. I want the icons from PagerTitleStrip to be displayed transaprently and party on the viewPager's content.
Any suggestions are highly appreciated.
I don't think it's possible to do this with the built-in ViewPager and PagerTitleStrip. You will have to make your own custom component based on these to get the effect you're looking for.

Categories

Resources