Android 2.2 Tab Layout
- November 25th, 2010
- Posted in Android
- Write comment
This is a code example for a Tab Layout for Android (2.2 Froyo).
The code is pretty straightforward…
Each tab has its own layout file and activity already created and working. This should be a little step forward for those who are struggling to upgrade the basic tab code provided on the Android Dev Guide.
For each tab I am using a TableLayout within a RelativeLayout to better display content (I strongly recommend this structure).
Eclipse Project Download : Android_TabLayout (5064)
Enjoy.
Walter


Thanks Walter for this project sample! I’m going to try this right away!
Thanks this is exactly what i was looking for.
Thanks !
Thanks a lot – From VN
Hi, thank’you very much for the tutorial.
One consideration: I discovered that if you specify a min sdk version in your andorid manifest above “4″
the look and feel of tabs backgrounds changes…
The selected tab bk is dark grey whereas the others are black. This has an impact on your icons especially if you follow the Android gudelines for icons (http://developer.android.com/guide/practices/ui_guidelines/icon_design_tab.html) you end up that you have to invert the two status to make them visible on sdk >= 5.
Then I have a question: is there a way to specify a special icon for a tab that has been set as not enabled?
ie. tabHost.getTabWidget().getChildAt(1).setEnabled(false);
I tried with
but it keeps using the “normal” state icon instead.
Thanks, Luca.
…ops the xml code is missing:
item android:drawable=”@drawable/ic_tab_checklist_disabled”
android:state_enabled=”false”
Thanks
That’s very good.I helped your code.
Good tut,
I wonder if there is a way to create tabs having an icon only and no text to meke them taller. I do not like these massive buttons and save some space.
Thanks
Thomas
Thanks a lot for the example. It really helped me to figure out the Tabs deal. The example of the TableLayout within a RelativeLayout is very useful as well.
YOU ARE MY ACTUAL HERO.
Had been struggling for ages trying to find a decent example / tutorial and the official Android tutorial wasn’t working at all.
This did, thank you so much!!
good one man!!Simplicity, just what was needed!
Thank you so much.I have take long time spend this tab concept in android 2.2.
This is nice post. It’s help me lot to complete my task. Check this URL
http://mindstick.com/Articles/7e659092-3046-4461-97ba-b2b28616241e/?tab%20layout%20android%20application
It’s also helpful and easy understandable. It might be useful for you.
Thanks!!!
thanka a lot for this posting!!!it really helps new comers to understand the thing with the help of an example like this!!!
I truly appreciate this article post. Really Cool.
Thanks for the source code