TabLayout indicator only slides betwee adjacent tabs - android

I've recently implemented the TabLayout within my AppBarLayout & CoordinatorLayout. It works fine except for one issue: the indicator doesn't slide to non-adjacent tabs. That is, when I tap on a tab that is not immediately adjacent to the currently selected tab it will hide and reappear under the newly selected tab. Is there something wrong I might be doing?
When looking at other Google Apps (i.e. Youtube) this is not the behavior I see. Instead I see the indicator smoothly slide over to the tab (even if it's not adjacent to the previously selected one).
Is there a way I can mimic the Youtube tab behavior?
Thanks
EDIT:
I've created gifs of youtube tabs and my tabs. Notice how Youtubes tab indicator never disappears.
YouTube Tabs:
My Tabs:

Related

problem with viewpager2 and bottomnav working together in android studio

so I'm trying to make small application type of thing where it has bottom navigation bar and viewpager2 working in it. But I want it so that in the first fragment page that application loads in, only there viewpager2 is available to work and be able to swipe, when I switch to next fragment with navigation bar that viewpager2 should basically disappear and not work, therefore my logic was to put that viewpager2 in that single fragment and navigation bar outside in main activity for it to be able to be seen in every fragment. But there is a problem, it almost works, I switch to another fragment with bar view pager disappears but when I go back to that first fragment view pager is just gone, disappeared and I have no idea what's the problem. if necessary I can show what I have written. Thanks in advance

Focus is lost on tabs in a tablayout with a viewpager

I have a Fragment which contains a TabLayout with a ViewPager. These tabs are 3 different Fragments. The problem is that when I am in the first tab for example and I press the TAB button on an external keyboard or using Vysor app, the focus moves through the different tabs but the user still sees the first tab. Is it possible to keep the focus on the tab that the user is viewing or change tabs as the focus moves?

Difference between Tab Layout and ViewPager?

I'm learning about tab layout because I need to use tab layout.
When i search for tab layout on Google, the one that comes up together is the view pager.
By the way, I'm not sure about the difference between tablayout and viewpager.
The tab layout has a menu at the top and screen switching is possible.
Although the view pager does not have tabs, it is possible to slide the screen just like the tab layout.
But why use the two together?
What's different?
Isn't it possible to slide in tab layout as well?
Yes, you can use TabLayout without viewPager. But without viewpager you won't be able to slide your page. You have to handle tabselect listener manually using this method then you have to click on the tab to navigate.
addOnTabSelectedListener(OnTabSelectedListener)
Likewise, you can use only Viewpager then you will be able to slide or swipe your page without any tabs.
From official doc
TabLayout
TabLayout provides a horizontal layout to display tabs.
Viewpager
Layout manager that allows the user to flip left and right through pages of data.
So Tablayout and viewpager are two different things but you can have the privilege of both tabs and slide only by combining them.
You can check here for tablaout without viewPager
TabLayout without using ViewPager

swipe tabs by sliding in one fragment not using other fragments

I have a Fragment with TabLayout, and selecting by current tab it shows the selected month info, not hiding tabs bar and don't using for that many fragments, just updating the view. And now i need swipe tabs by finger sliding. I've searched and watch many examples which using ViewPager and many Fragments to describe each tab.
So how can i do this using only one fragment not other fragments?

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

Categories

Resources