3

I am using 2.2 SDK version. and i used TabHost to display the activity in tab view format. when i install application in mobile phone(Version 2.2.1), the tab host color has been changed into yellow color. Even i dint give any color to TabHost. i dont know why the color has been changed. The same application when i run in emulator, it displays default color(ie) gray and black. can anyone faced and solved this issue pls guide me. Here the code

`

    mTabHost.addTab(mTabHost.newTabSpec("one").setIndicator("classA").setContent(new Intent(this, classA.class)));
    mTabHost.addTab(mTabHost.newTabSpec("two").setIndicator("classB").setContent(new Intent(this, classB.class)));
    mTabHost.addTab(mTabHost.newTabSpec("three").setIndicator("classC").setContent(new Intent(this, classc.class)));`
RAAAAM
  • 3,378
  • 19
  • 59
  • 108
  • it's not issue it's feature ... tabhost using android default theme – Selvin Apr 22 '11 at 10:55
  • Yes you are right, but whenever i install application in mobile phone, the color has been changed into yellow color. – RAAAAM Apr 22 '11 at 11:04
  • so default theme on device isn't yellow ... could you provide TabWidget definition in layout file? and drawable selectors if any – Selvin Apr 22 '11 at 11:06
  • No i dint give any layout for this. – RAAAAM Apr 22 '11 at 11:09
  • so u didn't use setContentView in this activity ? maybe u changed theme in AndroidManifest.xml – Selvin Apr 22 '11 at 11:13
  • Yes i dint used SetContentView in this activity. I am not sure i made changes in AndroidMainfeast.xml. let me check. I gave admob ads to my application, is this made any changes to my application...??? – RAAAAM Apr 22 '11 at 11:24
  • @HariRam What is the default tabs color in your mobile phone (i.e. in other apps)? Are you sure it's not yellow? For instance, in my phone tabs are blue by default while other widgets are black-and-white. And be noticed that tab color is not a solid color. It is a set of drawables (PNG-files), so it's not easy to change tabs appearance, especially accidentally. – GrAnd Apr 22 '11 at 15:50

1 Answers1

22

In default android tab bar color will be in Grey, you can easily change the color of the tab bar.

Use the below line of code to change the color of Tab

     tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.RED);
or
     tabHost.getTabWidget().getChildAt(0).setBackgroundColor(Color.parseColor("#4E4E9C"));

For further Reference you can refer here.

If you are looking for iphonish Tabs you can refer this http://bakhtiyor.com/2009/10/iphonish-tabs/

Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104