Android TabHost at the Bottom of the Screen
http://www.viralandroid.com/2015/09/android-tabhost-at-bottom-of-the-screen.html
This is simple tip where, I am going to show how to align android TabHost at the bottom of the screen. If you have already used simple TabHost in your app then align tabhost at the bottom of the screen is very simple. If you haven’t used android tabhost, don’t worry. Here, I have provided complete XML and java code. You can also learn simple tabhost example here and android actionbar tabs example here. To make your tabs beautiful and attractive, you can find android tabs user interface design at Beautiful Mobile Tabs UI Design with Amazing User Experience.
If you are familiar with android TabHost then to align tab at the bottom of the screen, simply you have to add android:layout_alignParentBottom="true" in your TabWidget and layout margin bottom in Frame Layout. Following are the simple steps to align your tabhost at the bottom of the screen.
Let’s start by creating a new android project to align TabHost at the bottom of the screen with following information.
Application Name: Android Tabs at Bottom
Company Domain: viralandroid.com
Package Name: com.viralandroid.androidtabsatbottom
Minimum SDK: Android 2.2 (API 8 Froyo)
Just drag and drop TabHost in your XML layout file or simply add following XML code in your XML layout. Again, I want to remind you not to forgot to add android:layout_alignParentBottom="true" in your TabWidget. Following is the final code of XML layout file.
res/layout/activity_main.xml
Now, to make tabhost working, you have to add little java code in your activity file. Following is the final code of java file.
src/MainActivity.java
Now, run your application. You will see tabhost at the bottom of the screen like above.
Download complete Android TabHost at the Bottom of the Screen example project source code from GitHub.
How to Align Android TabHost at the Bottom of the Screen
If you are familiar with android TabHost then to align tab at the bottom of the screen, simply you have to add android:layout_alignParentBottom="true" in your TabWidget and layout margin bottom in Frame Layout. Following are the simple steps to align your tabhost at the bottom of the screen.
Create a new Android Project
Let’s start by creating a new android project to align TabHost at the bottom of the screen with following information.
Application Name: Android Tabs at Bottom
Company Domain: viralandroid.com
Package Name: com.viralandroid.androidtabsatbottom
Minimum SDK: Android 2.2 (API 8 Froyo)
Add TabHost in XML Activity File
Just drag and drop TabHost in your XML layout file or simply add following XML code in your XML layout. Again, I want to remind you not to forgot to add android:layout_alignParentBottom="true" in your TabWidget. Following is the final code of XML layout file.
res/layout/activity_main.xml
Modify Java Code
Now, to make tabhost working, you have to add little java code in your activity file. Following is the final code of java file.
src/MainActivity.java
Now, run your application. You will see tabhost at the bottom of the screen like above.
Download Complete Example Project
Download complete Android TabHost at the Bottom of the Screen example project source code from GitHub.