Hi all!
While developing Android application we needed Iphone like tab bar at the bottom of the screen, so Googled and find usefull links but having some issues.
Some of the usefull links I found were.
and so many links.
These posts are good and useful also.
But I was curious about having TabWidget and TabHost not using any other controller like some of authors have used RadioButtonGroup and Repeated Image Background.
So I searched about customizing android TabIndicator and found a solution.
The files which will be needed are as follows:
in res/drawable directory:
in res/layout directory:
Here we will see how the tab_focus.xml will look.
the remaining xml drawable will also be something like this but with little changes to show their related effects.
The tab_indicator.xml in layout folder will be as follows:
The main.xml will be same as usual layouts are defined but the TabWidget will be placed at the bottom.
so in Java side while defining TabActivity it will looks like this.
the addTab(); method will get the String id as text indicator and Drawable Id as to show the icon of the tab.
When we will compile and run the code we will se the iPhone Tabs in Android app.
We can change the color of the Tab Bar in under res/color.xml
by replacing Dark and relevent Medium color we can change the Tab look.
The app will look like this.
The best thing in this approach is we can add tabs as we add usual tab in Android.
Fully Satisfied.
The full source code is available for download HERE.
Happy Coding!
Regards.
While developing Android application we needed Iphone like tab bar at the bottom of the screen, so Googled and find usefull links but having some issues.
Some of the usefull links I found were.
and so many links.
These posts are good and useful also.
But I was curious about having TabWidget and TabHost not using any other controller like some of authors have used RadioButtonGroup and Repeated Image Background.
So I searched about customizing android TabIndicator and found a solution.
The files which will be needed are as follows:
in res/drawable directory:
- tab_selected.xml (will be used to show effect while selected)
- tab_pressed.xml (will be used to show effect while pressed)
- tab_unselected.xml (will be used to show effect while unselected)
- tab_focus.xml (will be used to show effect while focused)
- tab_indicator.xml (will be used to show effect while to sum up all the states)
in res/layout directory:
- tab_indicator.xml (Layout of the tab indicator which will include image)
- main.xml (Layout containing TabWidget and TabHost)
- mock.xml (Layout for mock Activity)
- color.xml (Color definition as resource)
- strings.xml (Strings as resource)
- dimentions.xml (Dimentions will be used to set size of components)
- styles.xml (Define Style etc.)
Here we will see how the tab_focus.xml will look.
the remaining xml drawable will also be something like this but with little changes to show their related effects.
The tab_indicator.xml in layout folder will be as follows:
The main.xml will be same as usual layouts are defined but the TabWidget will be placed at the bottom.
so in Java side while defining TabActivity it will looks like this.
the addTab(); method will get the String id as text indicator and Drawable Id as to show the icon of the tab.
When we will compile and run the code we will se the iPhone Tabs in Android app.
We can change the color of the Tab Bar in under res/color.xml
<color name="tabMedium">#4F4F4F</color>
<color name="tabDark">#3F3F3F</color>
<color name="tabDark">#3F3F3F</color>
by replacing Dark and relevent Medium color we can change the Tab look.
The app will look like this.
The best thing in this approach is we can add tabs as we add usual tab in Android.
Fully Satisfied.
The full source code is available for download HERE.
Happy Coding!
Regards.