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.
Related
I have a tab in the middle of a page, the tab is inside a listView, to render the the tab I had to set a fixed height on it, but the problem is that the content of the tab it will vary, it can have 1 or more items, how can I make the tab height dynamic?
I've answered at in the similar question.
https://stackoverflow.com/a/57558695/5541523
Maybe it could help you.
P.s. You will need to add GestureDetector if you want to change tabs on swipe.
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.
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.
I received a design where I have a custom tabbar, and one of the tabbar's tabs is bigger than the others.
This part was easy to do, but that bigger portion of the tab was suposed be over the tabcontent object, so when the content get scrolled, that tab will be 'floating' over it.
This was what I got first:
I seted the magin_top of the tabcontent to -4dip (size of the bigger portion) and the content moved up, but it moved over the tabwidget.
This is what happened then:
I'm new to android development, so I tried to look for anything like a z-index, I found a bringToFront() and a bringToFromChild(), but I guess they were not what I was looking for.
This is what I'm trying to do:
Where the red is the content of a tab
Set the same Red background in parent container of tab-widget layout file so you can get a View like the last image.
I'm not really sure what tools I should be using to create a desired outcome...
At the bottom of the screen I would like to have three buttons, something like what is at the bottom of this screen except only using text instead of icons, and only having three options, not four.
Is this a tab view? I don't need a tab view because I don't need the tabs to stay on screen after one is clicked.
According to the layout source for the DeskClock they are indeed image buttons in a linear layout. The main layout source shows that the buttons are 'included' with the main layout. Hopefully this source helps.