Change text size on tabHost

kavain picture kavain · Sep 27, 2012 · Viewed 12.6k times · Source

I'm trying to do a tabHost with 2 tabs, its ok, but i want to change text size, I search a lot but I don't find anything without change all layout of tab, i just want change text size, not change background or anything like that, i add my tabs like this:

tabHost.addTab(tabHost.newTabSpec("photos_tab").setIndicator(getString(R.string.userPhotos)).setContent(R.id.tab2));

when I try to put a TextView in setIndicator its work and I can change text size but change everything, click, background and other things.. so I want to change only text size.

any ideas?

ps: I'm not extend TabActivity, so I can't change Theme in AndroidManifest or something like this. (I tried it before: How to change the font size of tabhost in android)

Thanks.

Answer

Hardik4560 picture Hardik4560 · Sep 27, 2012

Yes, You can do that by getting the child at a specified position and getting its textview and setting the textsize of it.

 TextView x = (TextView) tabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title);
    x.setTextSize(25);