Change text size on tabHost
Asked Answered
R

1

5

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.

Rosinweed answered 27/9, 2012 at 14:51 Comment(0)
A
23

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);
Abagael answered 27/9, 2012 at 15:6 Comment(5)
Thanks very much, its work very well, but have anyway can i do this when i setIndicator?Rosinweed
I tried using Html.fromHtml() but it didn't worked with tabWidgets, so for now the only option is set it explicitly.Abagael
@thamerhatem No. You have to do this after you added the TabSpec to the TabHost: tabHost.addTab(tabSpec)Kirwin
It always returns a Null Pointer Exception. I couldn't find the textview. :( Help.Hedgehog
@princepiero, Sebastian is right, you need to use this after you add specs to tab host. And you have to do this for every tab.Thereby

© 2022 - 2024 — McMap. All rights reserved.