How not to wrap the Tab Titles in Swipe View? - android

I am trying to create swipe able views in android.
But since titles of my Tabs are longs they are getting wrapped to fit in single screen.
How to avoid the wrapping of titles and let the titles extend in one line even if the tab titles has to expand outside the current screen.
Seen Image Here

There is an Android component for that called PagerTitleStrip: http://developer.android.com/training/implementing-navigation/lateral.html#PagerTitleStrip
This will provide you fully-visible scrollable tabs.

Related

Align TabLayout titles left and right

I am working on a little dictionary app which currently looks like this:
I want the start of the first tab title and the end of the last tab title to be aligned with the start of péngyou and the end of HSK 1.
I tried using custom layouts for the first and last tab aligning the text left and right and using the correct padding, but that leaves me with two problems.
The distribution of the tab titles looks off. I guess tabs originally have equal width and the titles are centered in their respective tab. Do I have to calculate the positioning for the remaining tab titles myself? How could I achieve that
I use tabIndicatorFullWidth="false", but the tab indicator gets centered in the tab instead of being aligned with the title. Do I have to overwrite the tab indicator behavior? If yes, where would I do that and how could I achieve alignment regardless of where the title is aligned in the tab?
Did I miss an easy solution to this problem?
I managed to solve my problem by using tabMode="scrollable" and a custom TabLayout. In the onMeasure function of the TabLayout I calculatted the width each tab should have and added paddings accordingly.

Android Xml command meanings?

Hi my question is related to some xml commands used in material design designs. I don't understand what some commands mean in Toolbar and TabLayout. Is there anyone have an idea? What do the numbers of commands mean?
Toolbar
app:layout_scrollFlags="5"
TabLayout
app:tabGravity="0"
app:tabMode="1"
You should look at the official docs
For tabGravity
GRAVITY_CENTER Gravity used to lay out the tabs in the center of the TabLayout.
GRAVITY_FILL Gravity used to fill the TabLayout as much as possible. This option only takes effect when used with MODE_FIXED.
MODE_FIXED Fixed tabs display all tabs concurrently and are best used with content that benefits from quick pivots between tabs. The maximum number of tabs is limited by the view’s width. Fixed tabs have equal width, based on the widest tab label.
MODE_SCROLLABLE Scrollable tabs display a subset of tabs at any given moment, and can contain longer tab labels and a larger number of tabs. They are best used for browsing contexts in touch interfaces when users don’t need to directly compare the tab labels.
For tabMode ="fixed" or "scrollable"
MODE_FIXED: Fixed tabs display all tabs concurrently and are best used with content that benefits from quick pivots between tabs.
MODE_SCROLLABLE: Scrollable tabs display a subset of tabs at any given moment, and can contain longer tab labels and a larger number of tabs. They are best used for browsing contexts in touch interfaces when users don’t need to directly compare the tab labels. This mode is commonly used with a ViewPager.
For scrollFlags -> here

align PageTabStrip according to the custom ViewPager content width

I have created PageTabStrip and ViewPager to show multiple list fragments. inside my app viewpager content has a specific width ( it doesn't occupy the whole screen ) partial pages are visible.
as my ViewPager content has specific width, my PageTabStrip are not aligned accordingly.
please see the image below , so how do i align the Division caption under first list and Item under second list ( second tab is getting out of the screen , see in red)
![enter image description here][1]
I think you misunderstand the concept of viewpager and PageTabStrip and misused them with your design requirement.
The viewpager is a widget that shows each page one at a time and when you swipe you can see the other pages. Other pages are all invisible until you swipe to them, then it shows you one at a time.
The pageTabStrip helps you to find that which page is currently displayed and what is the title of the next page and previous page if you swipe to those, so it just gives a hint about next and previous pages.
What your picture tells us is you have created a page and set its title Division,(as the pageTabStrip shows) and you have put all of your layouts inside it and you called the next page title ITEM but I think if you swipe to it, it is either empty or just duplicates current view. Your problem is here, if you put all your layouts inside one page you can not set different title for different part of current page, you only can set one title and this title applies to whole layout of current page.
Here is my different solutions to represent your layout:
1) Do not use pageTabStrip or give it a general title for example Search and provide a sub title for each part of current layout with for example linearlayout. It means add a linearlayout above the current page and divide it and put each subtitle in a correct position.
2) Use dual pan fragment design pattern and remove the viewpager.
3) Move search item type section to the next page.

Listview in scrollable layout

Don't use listviews in scrollviews they say, well, okay, but how do you fix this?
I have a viewpager with some lists in it (mockup)
above that, I have a tabindicator and some other information that doesn't change when you go to another tab.
My problem is that I always want to scroll the complete view (so content, tabindicator and viewpager).
If you scroll down, only the fragment with the listview (=tab content) should be visible and scrollable.
I don't want to put the content view and tab headers in a listview header because I don't want them to change every time I go to another tab (swipey tabs, so the user will see it)
What's the best way to do this?

Android ListView in a ViewPager below a static layout

I'm trying to create a layout for my activity, but am not sure what the best way to do this is. What I want is a ViewGroup on top with some user's information. Then, below that (filling the rest of the vertical space), I have a ViewPager that hosts two ListFragments. Both ListFragments contain dynamic feeds relevant to the user.
This works fine, but what I would like to have is something that would scroll the top profile stuff out of view as the ListFragments in the ViewPager is scrolled. Attaching HeaderViews to the ListViews don't make sense since I only want the user to swipe between feeds not the feed + static HeaderView, and neither does putting the ViewPager + ListViews in a ScrollView root. Any ideas on a good way of making this layout?

Categories

Resources