更改tab​​Host文字大小 [英] Change text size on tabHost

查看:213
本文介绍了更改tab​​Host文字大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

<$p$p><$c$c>tabHost.addTab(tabHost.newTabSpec("photos_tab").setIndicator(getString(R.string.userPhotos)).setContent(R.id.tab2));

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

什么想法?

PS:我不是延长TabActivity,所以我不能改变主题的Andr​​oidManifest或这样的事情。 (我尝试过:<一href="http://stackoverflow.com/questions/5788971/how-to-change-the-font-size-of-tabhost-in-android">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);

这篇关于更改tab​​Host文字大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆