I am new to Android development. The app on which I am working requires white action bar background and the title should be black in color. I am using support library for lower compatibility.
Style.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
How can I do this ?
Styles : Main App Theme
<style name="MyAppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/CustomActionBarStyle</item>
</style>
Setup styles for text and background color
<style name="CustomActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/white</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="background">@color/white</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
Setup TextColor Impt: parent must @style/TextAppearance.AppCompat.Widget.ActionBar.Title
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/action_bar_text_color</item>
</style>
For more refer links posted in @Santosh Shinde post
Use This to change title color
ActionBar actionBar = getActionBar();
actionBar.setTitle(Html
.fromHtml("<font color='#ffffff'> Now playing </font>"));
and for action bar title
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.rgb(0, 0, 0)));
or
getActionBar().setBackgroundDrawable(
new ColorDrawable(Color.parseColor("#000000")));
Try this style:
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:buttonStyle">@style/Button</item>
<item name="android:editTextStyle">@style/EditText</item>
<item name="android:windowBackground">@android:color/black</item>
</style>
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundStacked">@color/core_other_light</item>
<item name="android:backgroundSplit">@color/core_other</item>
<item name="android:background">#00ff00</item>
</style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.