我想更改操作栏中的文字颜色。我尝试了很多东西,但无法改变它。在图片中我想将单词组更改为白色
这是我的styles.xml文件:
<resources>
<!-- Base application theme. -->
<style name="MyCustomTheme" parent="android:style/Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:actionBarStyle">@style/MyCustomTheme.MyActionBar</item>
<item name="android:textViewStyle">@style/MyTextViewStyle</item>
<item name="android:buttonStyle">@style/MyButtonStyle</item>
<item name="android:editTextStyle">@style/MyEditTextStyle</item>
</style>
<style name="MyCustomTheme.MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/colorPrimary</item>
<item name="android:textSize">@dimen/edit_text_text_size</item>
</style>
<style name="MyTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">@string/app_font</item>
<item name="android:textSize">@dimen/edit_text_text_size</item>
</style>
<style name="MyEditTextStyle" parent="android:Widget.EditText">
<item name="android:fontFamily">@string/app_font</item>
<item name="android:textSize">@dimen/edit_text_text_size</item>
</style>
<style name="MyButtonStyle" parent="android:Widget.Holo.Button">
<item name="android:fontFamily">@string/app_font</item>
<item name="android:textSize">@dimen/edit_text_text_size</item>
</style>
</resources>
这是我的操作栏: http://pichoster.net/lPd
答案 0 :(得分:0)
我认为这应该有用。
int titleId = getResources().getIdentifier("action_bar_title", "id", "android");
现在,您可以将ID
与TextView
TextView abTitle = (TextView) findViewById(titleId);
abTitle.setTextColor(colorId);