Google's FragmentTabs demo feels very hackish to me. Does anyone know a nice way to have fragment based tabs that do not rely on the ActionBar?
The ActionBar is not an option, because the tabs must appear somewhere else on the screen. Also, the ActionBar lacks in the support library.
Just wanted to check before I go on and build my own solution...
I used this implementation in my app and it works great. It does not require an ActionBar and uses Fragments with a ViewPager. I came across this if anyone is still interested...
SwipeyTabs
Also here is a blog post about it:
http://blog.peterkuterna.net/2011/09/viewpager-meets-swipey-tabs.html
TabActivity in the Android docs
has an example using fragments and the TabHost and TabWidget. Hope this helps.
Related
How would I go about implementing swipeable icon tabs as the main navigation in an app? Heres a screenie of the popular Flipboard app, which demonstrates what im looking for: http://prntscr.com/83607c
I have been looking for an answer to this question for almost a week now, and have asked on several communites yet no one seems to be able to answer how to go about doing something like this. I'm assuming its a ViewPager for the swipeable part, but the only thing I can think of for the tabs would be a TabLayout, but this implements tabs "below" the toolbar, eg: http://prntscr.com/83674c which is not what i'm looking for.
Google recently released Support Design library. Witch contains all the necessary views. You can read more here
The views you are interested:
TabLayout and
TabLayouts.Tab
In my Android application I have had to use a tab layout and I want to choose a one from folowing scenarios. they are
using viewPager
using tab host
what are the advantages of viewPager over tabhost. Which one is better. And I'm targeting the android 4.2. Thank You!
It actually depends on what you want and the type of content you are putting in application.
ViewPager:
It is supported in lower API with support library and Sherlock library is always there.
Using ViewPager will give a fresh and distinctive feel to the app. For this you'll need to use fragments. Which are complicated but great in terms of performance and are replacable(a superb feature).
ViewPager
TabHost:
This is achievable using both Fragments and Activities. Although in favour of FragmentTabHost, TabActivity has been deprecated. However if you are not experienced with Fragments, use Activities, but you can always migrate to fragments later. FragmentTabHost
You should check out different tutorials and implement both of them, then decide. You should learn fragments if you embark on using ViewPager. For which, Check this
This blog has numerous examples of tabs. It can help you decide.
I found it very painful to customize tab host such as increasing indicator height, have to create 9 draw batch and customize background and many things.
With tab layout, only one line of code https://developer.android.com/reference/android/support/design/widget/TabLayout.html#setSelectedTabIndicatorHeight(int)
So, I recommend using view pager with tab layout that provides the same UX. Tab host is not deprecated, but it will happen soon, I guess :P
I am writing one application where i want to follow latest design guidlines for android. And now i want to use TABS as in 4.0 there is not recommended to use TabWidgets anymore and it is recommended to use Navigation Tabs i checked this http://developer.android.com/guide/topics/ui/actionbar.html - At navigation tabs
But i dont realy understand how i am able to do this. Dont know where to include this ActionBar.TabListener etc. Are there any more detailed tutorials for this or does anyone here have any detailed code.
Thank you!
Here is a good example of using Action Bar:
http://www.java2s.com/Code/Android/UI/Usingactionbartabsandhowtheyinteractwithotheractionbarfeatures.htm
Also some good examples here:
Actionbarsherlock + tabs + multi fragments?
Check this ActionBarSharelock and the same thing on Github.
I just encountered a problem in layout design with tabhost.
i need exactly the same design so that on selecting a tab it will come in cented of the screen. with design like in these pictures.
Currently ViewPagerIndicator is the best resource for getting this done without too much code. As for the same design you're going to have to do a little work yourself to get that done. If you look through the samples on the projects github you'll see some examples of how the ViewPagerIndicator can be themed.
http://viewpagerindicator.com/
Can I implement a tab host which will remain in overall application and works through out the application .
and
Also can i implement the tab host on the top and on the bottom of the same activity.
Any tutorial any help please....
Thanks
This is possible if you use Activity Group. But still it is deprecated and hence you cannot use it for newer versions of android. But still, you can go through what it is and try to implement it.
ActivityGroup Example
http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/
http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity
So now since Activity Groups are deprecated what is the alternate strategy we can make use of? Here is the solution for this problem.
Go for fragments or Views.
I have pasted the comment which I recieved from Commonsware regarding the ActivityGroup.
You never needed ActivityGroup to use tabs. You can put views in tabs, for example (github.com/commonsguy/cw-android/tree/master/Fancy/Tab). Going forward, tabs are in the action bar on Honeycomb, typically using fragments. You can achieve the same functionality on previous versions of Android using ActionBarSherlock.