Getting the width of an action bar tab - android

I want to have an action bar with tabs and a viewPager for the body in order to be able to scroll the tabs.
I also want to have a view to "underline" the selected tab, and have it move when I scroll the viewPager.
Is there a way to get the size of the tab? Since I'm different devices the tabs may be scrollable I can't just divide the size of the screen by the amount of tabs..
I want it to be something like this:

Related

Move top navigation bar along with the screen

I think the way I was going is wrong. I wanted to create a top navigation bar which has 3 items so I created tabs and with a View Pager, I used 3 fragments for each tab. That way I can slide screens between each other, but the tabs are not moving along with the screen.
Can someone suggest me how to make top navigation bar items moving along with the screen is sliding?
This video explains exactly what I want. Please note how the top bar items are moving along with the screen.
https://drive.google.com/file/d/1OzDFR4VT_YyDumEZLOWtGZ-_5BLXAfK4/view

Handle Scrolling in Android AppbarLayout

I need to handle the scrolling behaviour in my app. I have a screen with Colloapsing toolbar and tablayout viewpager. In this tablayout i have 3 tables.
First tab is content description. Second Tab and Thired Tab contains the List items.
Here the content of description and the list items is small i want to disable the appbar scrolling for each tab. If the content is large or list item is larger have to enable the appbar scrolling. Can any one know how to handle this..

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

TabsActivity leaves a vertical gap when adding a view next to tabs using Tabs Activity

I am trying to put a view horizontally on the right side of the tabs. If i put a view next to tabs, the activity displayed in tabs does not cover the region which is outside tabs thus it leaves a gap for that view. Does anyone know how to fix this.
Temporarily, I am using views instead of Tabs which made my layout very complex.

How to show small tab interfaces in ordinary activities (non-tabactivity)?

I wish to show tabs in an activity such that one of the tabs will be a comment form and the other tab will be a list of comments submitted by other users of the application.
I do not wish to implement it as a TabActivity - where the whole screen is occupied by the view, with the tabs at the top. I wish to show this tab interface below a image both of which will be in a <LinearLayout android:orientation="vertical">.
How do I accomplish this?
You can give a layout to TabActivity where you have LinearLayout on the top as you desired and then the tabs

Categories

Resources