更改tab​​Host文字大小文字大小、tab、Host

由网友(处女往往给了狗。)分享简介:我试图做一个tabHost有2个选项卡,其确定,但我想改变文字大小,我搜索了很多,但我不觉得没有任何改变标签的所有的布局,我只是想改变文字大小,没有改变的背景之类的东西,将我的卡是这样的:tabHost.addTab(tabHost.newTabSpec("photos_tab").setIndicator(getSt...

我试图做一个tabHost有2个选项卡,其确定,但我想改变文字大小,我搜索了很多,但我不觉得没有任何改变标签的所有的布局,我只是想改变文字大小,没有改变的背景之类的东西,将我的卡是这样的:

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

当我试图把一个TextView在setIndicator的工作,我可以改变文字大小,但改变了一切,点击,背景和其他的东西..所以我只想更改文字大小。

什么想法?

PS:我不是延长TabActivity,所以我不能改变主题的Andr​​oidManifest或这样的事情。 (我尝试过:How改变tabhost的机器人字体大小)

感谢。

解决方案

是的,你可以做到这一点通过让孩子在规定的位置,并获取其TextView中并设置它的TEXTSIZE。

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

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.

解决方案

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);

阅读全文

相关推荐

最新文章