我试图在我的style.xml中设置Android标签文本颜色:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FFFFFF</item>
<item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
</style>
<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
<item name="android:textColor">#000000</item>
</style>
我的View寻呼机就是这样:
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"/>
然而,使用这些代码,我只设法将视图寻呼机标签背景颜色更改为白色,但文本也更改为白色。我想知道为什么我为动作栏设置文本颜色的部分不起作用。
提前致谢。
修改
我设置浏览器的部分:
public class EventDetailMain extends FragmentActivity {
Context context = this;
ViewPager Tab;
EventDtlTabPagerAdapter TabAdapter;
ActionBar actionBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.event_detail_main);
TabAdapter = new EventDtlTabPagerAdapter(getSupportFragmentManager());
Tab = (ViewPager) findViewById(R.id.pager);
Tab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar = getActionBar();
actionBar.setSelectedNavigationItem(position);
}
});
Tab.setAdapter(TabAdapter);
actionBar = getActionBar();
// Enable Tabs on Action Bar
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
public void onTabReselected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
}
public void onTabSelected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
// on tab selected show respected fragment view
Tab.setCurrentItem(tab.getPosition());
}
public void onTabUnselected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
}
};
// Add New Tab
actionBar.addTab(actionBar.newTab().setText("Event Detail")
.setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Chat Room")
.setTabListener(tabListener));
actionBar.addTab(actionBar.newTab().setText("Drop Review")
.setTabListener(tabListener));
}
答案 0 :(得分:0)
我相信Tab的文字有一种风格试试这个:
添加此主题
<item name="android:actionBarTabTextStyle">@style/ActionBar.TabText</item>
然后将标签文本样式声明为以下
<style name="ActionBar.TabText" parent="">
<item name="android:textColor">#888</item>
</style>
答案 1 :(得分:0)
通过将样式的父级更改为主题的操作栏标题来尝试此操作:
<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#000000</item>
</style>
答案 2 :(得分:0)
确定请尝试查看文档(http://developer.android.com/guide/topics/ui/actionbar.html):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!--IMPORTANT FOR YOU -->
<item name="android:actionBarTabTextStyle">@style/TabTextStyle</item>
<item name="android:actionMenuTextColor">@color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="actionBarTabTextStyle">@style/TabTextStyle</item>
<item name="actionMenuTextColor">@color/actionbar_text</item>
</style>
<!-- general styles for the action bar -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/TitleTextStyle</item>
<item name="android:background">@drawable/actionbar_background</item>
<item name="android:backgroundStacked">@drawable/actionbar_background</item>
<item name="android:backgroundSplit">@drawable/actionbar_background</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">@style/TitleTextStyle</item>
<item name="background">@drawable/actionbar_background</item>
<item name="backgroundStacked">@drawable/actionbar_background</item>
<item name="backgroundSplit">@drawable/actionbar_background</item>
</style>
<!-- action bar title text -->
<style name="TitleTextStyle"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_text</item>
</style>
<!-- action bar tab text IMPORTANT FOR YOU -->
<style name="TabTextStyle"
parent="@style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">@color/actionbar_text</item>
</style>
答案 3 :(得分:0)
我们假设你有一个自定义主题:
<style name="TabTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:textColorPrimary">@color/colorPrimaryDark</item>
<item name="android:textColorSecondary">@color/colorPrimaryDark</item>
</style>
请注意
parent="Theme.AppCompat.Light.DarkActionBar"
可以是您已有的任何其他主题,只要它继承自标准的Android主题。我只是用DarkActionBar作为例子。
android:textColorPrimary属性将用作选定标签的文本颜色,而android:textColorSecondary将用作未选择标签的文本颜色。
我希望这对你有用,就像对我一样。