如何在android中更改tabhost的字体大小 [英] How to change the font size of tabhost in android

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

问题描述

如何改变标签的字体大小?我为标签扩展了 TabActivity.

How can the font size of the tabs be changed? I extend TabActivity for the tabs.

推荐答案

你可以定义主题,使用样式来实现:

You can define themes, use styles to achieve this:

首先在 res/values/styles.xml 中为 Activity 创建主题(名称:CustomTheme):

First you create the theme (name:CustomTheme) for your Activity in your res/values/styles.xml:

<style name="CustomTheme" parent="@android:style/Theme">
    <item name="android:tabWidgetStyle">@style/CustomTabWidget</item>
</style>
<style name="CustomTabWidget" parent="@android:style/Widget.TabWidget">
    <item name="android:textAppearance">@style/CustomTabWidgetText</item>
</style>
<style name="CustomTabWidgetText" 
    parent="@android:style/TextAppearance.Widget.TabWidget">
    <item name="android:textSize">20sp</item>
    <item name="android:textStyle">bold</item>
</style>

然后在您的 androidManifest.xml 中为包含您的 TabWidgetTabActivityActivity 指定上述主题:

Then in your androidManifest.xml you specify the theme above for your TabActivity or Activity containing your TabWidget:

<activity android:name="MyTabActivity" android:theme="@style/CustomTheme">

这将为您提供所需的输出(当然,您应该根据自己的喜好更改大小和样式).

This will serve you with the output you want (of course you should change the size and style for your preference).

这篇关于如何在android中更改tabhost的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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