0

I want to make the tabbar of Android to look like Android.

Here is my code:

main.xml

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@android:id/tabhost"
    android:orientation="vertical" >

    <TabWidget 
        android:layout_width="fill_parent"
    android:layout_height="40px"
        android:id="@android:id/tabs"
            android:layout_alignParentBottom="true"


        ></TabWidget>



</TabHost>

TabActivity.java

package com.saa;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;


public class TabActivity extends android.app.TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TabHost tabHost=getTabHost();
        Intent intent = new Intent();
        TabSpec tabSpec= tabHost.newTabSpec("one");
        tabSpec.setIndicator("One", getResources().getDrawable(R.drawable.ic_launcher));
        intent.setClass(this, tab1.class);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);


        tabSpec= tabHost.newTabSpec("two");
        tabSpec.setIndicator("Two", getResources().getDrawable(R.drawable.ic_launcher));
        intent = new Intent().setClass(this, tab2.class);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);

        tabSpec= tabHost.newTabSpec("three");
        tabSpec.setIndicator("Three", getResources().getDrawable(R.drawable.ic_launcher));
        intent = new Intent().setClass(this, tab3.class);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);

        tabSpec= tabHost.newTabSpec("four");
        tabSpec.setIndicator("Four",getResources().getDrawable(R.drawable.ic_launcher));
        intent = new Intent().setClass(this, tab4.class);
        tabSpec.setContent(intent);
        tabHost.addTab(tabSpec);

        tabHost.setCurrentTab(0); // default tab
    }

}

What are the changes do I need to make in order for the Tabbar to got down? I have created other classes like tab1.java,tab2.java etc..

Samrat Mazumdar
  • 2,641
  • 4
  • 19
  • 28
  • 1
    [Have a look at this post](http://stackoverflow.com/a/6992662/593709) – Adil Soomro Jun 16 '12 at 14:59
  • @AdilSoomro Thanks! But can you just look into the code I have written and point out how to change there. Will help me a lot – Samrat Mazumdar Jun 16 '12 at 15:25
  • 1
    Just my 2 cents: Don't do it. The users decided to buy an Android device for different reasons. They didn't want an iPhone. So it's totally ok to stick to the default Android look. Nothing helpful, I know, but just think about it for a second. – henrik Jun 16 '12 at 16:58
  • @henrik One of my friend challenged me to do this, this is only for knowledge. Will not be implementing it in real scenario. – Samrat Mazumdar Jun 16 '12 at 17:13
  • 3
    @henrik - And some people buy and android because they are cheaper than an iPhone, not because they didn't want an iPhone LOL!!! – trumpetlicks Jun 16 '12 at 18:16

0 Answers0