Android 如何在以编程方式创建选项卡时设置选项卡文本颜色
我在onCreate方法中创建了我的选项卡,但没有tabhost。如何以编程方式设置文本颜色?这是一个id为relativeLayoutTimeline的相对布局,如果有帮助的话Android 如何在以编程方式创建选项卡时设置选项卡文本颜色,android,colors,tabs,Android,Colors,Tabs,我在onCreate方法中创建了我的选项卡,但没有tabhost。如何以编程方式设置文本颜色?这是一个id为relativeLayoutTimeline的相对布局,如果有帮助的话 ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(true); T
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(true);
Tab tabHome = actionBar.newTab().setText("Home").setTag("HomeTimelineFragment")
.setIcon(R.drawable.home_icon).setTabListener(this);
愚蠢的迈克尔。你最好以这样的方式来做
<!-- The theme for the activity -->
<style name="TabSpecialTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="@android:attr/actionBarTabTextStyle">@style/TabStyle</item>
</style>
<!-- Modify the text color -->
<style name="TabStyle" parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
<item name="android:textColor">#F70000</item>
</style>
@样式/选项卡样式
#F7000
愚蠢的迈克尔。你最好以这样的方式来做
<!-- The theme for the activity -->
<style name="TabSpecialTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="@android:attr/actionBarTabTextStyle">@style/TabStyle</item>
</style>
<!-- Modify the text color -->
<style name="TabStyle" parent="android:Widget.Holo.Light.ActionBar.TabText.Inverse">
<item name="android:textColor">#F70000</item>
</style>
@样式/选项卡样式
#F7000
另一种可能的解决方案是为选项卡创建TextView文本,为每个选项卡设置Customview属性
TextView tView = new TextView(getActivity().getApplicationContext());
tView.setText(tab_name);
tView.setTextColor(Color.RED);
actionBar.addTab(actionBar.newTab()
.setTabListener(this)
.setCustomView(tView));
另一种可能的解决方案是为选项卡创建文本视图文本,为每个选项卡设置Customview属性
TextView tView = new TextView(getActivity().getApplicationContext());
tView.setText(tab_name);
tView.setTextColor(Color.RED);
actionBar.addTab(actionBar.newTab()
.setTabListener(this)
.setCustomView(tView));