0

I have created four tabs but want each tab to be a different block color - should this be done in the xml or java file? I'm assuming java because I only have one xml file for the whole tab widget.

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
codegirl
  • 21
  • 6

1 Answers1

1

try to customise the individual tabs try using something like

TabWidget tabWidget = getTabWidget();
for(int i = 0; i < tabWidget.getChildCount(); i++) {
RelativeLayout tabLayout = (RelativeLayout) tabWidget.getChildAt(i);
tabLayout.setBackgroundDrawable(someimage);
}
G_S
  • 7,068
  • 2
  • 21
  • 51
  • Thanks - I have white logo images ready for each tab but want a background colour for each. Or is there any way I can make the image stretch over the entire tab to get this effect? Thanks! :) – codegirl Sep 13 '12 at 16:29
  • i think tabLayout.setBackgroundDrawable(someimage); will set the image . I mean stretch the image (but not sure) – G_S Sep 13 '12 at 16:32
  • or have a look a look at http://ondrejcermak.info/programovani/custom-tabs-in-android-tutorial/comment-page-1/ – G_S Sep 13 '12 at 16:44
  • if this helped you try to please post a sample code that helped to solve your problem so that even others can use. – G_S Sep 14 '12 at 15:17