Android getActionBar().subtitle 改变颜色
Android getActionBar().subtitle Changing Color
使用此代码:
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#CFCAF3")));
我可以更改操作栏的颜色。
但是我想改变字幕的颜色。
getActionBar().setSubtitle("Tarih 2 Mayıs 2015");
但它是灰色的。见下图
但在这个应用程序中它是黑色的
如何更改字幕的颜色?
你需要在你的风格中定义它。假设您使用的是 AppCompat 主题样式
<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="subtitleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="textColor">@color/red</item>
</style>
在您的清单中,为 activity 创建一个主题。下面给出一个例子。
<activity
android:name="com.x.y.Mainact"
android:theme="@style/ActionBarTest"
在你的主题 ActionBarTest 中,
<style name="ActionBarTest" parent="android:Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
<item name="android:textColorSecondary">@color/black</item>
</style>
项目
textColorSecondary
这就是我们的诀窍。
使用此代码:
getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#CFCAF3")));
我可以更改操作栏的颜色。
但是我想改变字幕的颜色。
getActionBar().setSubtitle("Tarih 2 Mayıs 2015");
但它是灰色的。见下图
但在这个应用程序中它是黑色的
如何更改字幕的颜色?
你需要在你的风格中定义它。假设您使用的是 AppCompat 主题样式
<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="subtitleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="textColor">@color/red</item>
</style>
在您的清单中,为 activity 创建一个主题。下面给出一个例子。
<activity
android:name="com.x.y.Mainact"
android:theme="@style/ActionBarTest"
在你的主题 ActionBarTest 中,
<style name="ActionBarTest" parent="android:Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">@style/OverFlow</item>
<item name="android:textColorSecondary">@color/black</item>
</style>
项目
textColorSecondary
这就是我们的诀窍。