TabHost Android使文本加粗
我在寻找加粗文本的方法,基本上是制表符主机使文本加粗 示例图像如下所示 下面是我的代码TabHost Android使文本加粗,android,android-layout,android-intent,android-style-tabhost,Android,Android Layout,Android Intent,Android Style Tabhost,我在寻找加粗文本的方法,基本上是制表符主机使文本加粗 示例图像如下所示 下面是我的代码 tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if (tabId.equals("READING")) {
tabHost.setOnTabChangedListener(new OnTabChangeListener()
{
@Override
public void onTabChanged(String tabId)
{
if (tabId.equals("READING"))
{
for(int i=0;i< tabHost.getTabWidget().getChildCount();i++)
{
//unselected
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#E6A9EC"));
}
// selected
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.WHITE);
}
else
{
for(int i=0;i< tabHost.getTabWidget().getChildCount();i++)
{
//unselected
tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.parseColor("#E6A9EC"));
}
// selected
tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.WHITE);
}
}
});
tabHost.setOnTabChangedListener(新的ontabchangedListener()
{
@凌驾
已更改的公共无效项(字符串选项卡ID)
{
如果(制表符等于(“读数”))
{
对于(int i=0;i
您可以在自定义主题更改中设置样式
<item name="android:tabWidgetStyle">@android:style/Widget.TabWidget</item>
@android:style/Widget.TabWidget
及
@style/TextAppearance.Widget.TabWidget
帐篷
真的
14便士
大胆的
@android:颜色/选项卡\指示器\文本
我发现这是最简单的方法:将选项卡添加到TabHost后,请执行以下操作:
TextView textView = (TextView) tabHost.getTabWidget().getChildAt(i)
.findViewById(android.R.id.title);
“i”只是新选项卡的索引。在我的例子中,我使用了for循环。
之后,非常简单,只需执行以下操作:
textView .setTypeface(null, Typeface.BOLD);
希望这有帮助。您能更清楚地知道我应该在哪里添加代码吗。我在styles.xml中这样做了,但它不起作用。有没有一种用JAVA实现的方法?感谢您的帮助您的意思是将所选项目加粗,还是全部加粗?
textView .setTypeface(null, Typeface.BOLD);