Color of an Android app

Asked

Viewed 311 times

2

I’m trying to leave the app color as White (by default), but I can’t do it... Is that possible? Or will I have to define the element color per element?

I also can’t change the color of Actionbar, follow the relevant code:

<style name="Theme.David" parent="@style/Theme.AppCompat.Light">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:titleTextStyle">@style/TitleTextStyle.David</item>
    <item name="android:actionBarItemBackground">@drawable/selectable_background_david</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.David</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.David</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.David</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.David</item>
    <item name="android:actionBarStyle">@style/ActionBar.Solid.David</item>
    <item name="android:actionModeBackground">@drawable/cab_background_top_david</item>
    <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_david</item>
    <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.David</item>

    <item name="actionBarItemBackground">@drawable/selectable_background_david</item>
    <item name="popupMenuStyle">@style/PopupMenu.David</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.David</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.David</item>
    <item name="actionDropDownStyle">@style/DropDownNav.David</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.David</item>
    <item name="actionModeBackground">@drawable/cab_background_top_david</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_david</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.David</item>
</style>

<style name="ActionBar.Solid.David" parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/TitleTextStyle.David</item>
    <item name="android:background">@drawable/ab_solid_david</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_david</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_david</item>
    <item name="android:progressBarStyle">@style/ProgressBar.David</item>

    <item name="background">@drawable/ab_solid_david</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_david</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_david</item>
    <item name="progressBarStyle">@style/ProgressBar.David</item>
</style>

<style name="TitleTextStyle.David" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textStyle">bold</item>
</style>
  • Why don’t you use the theme Theme.AppCompat.Light just? If not this, create the directory res/values-14 and define the ActionBar.Solid.David with android:background and other attributes with the same prefix.

  • I deleted "Darkactionbar" and also included the items with the prefix "android:", but the color of the text and Actionbar remain black... I don’t understand what could be going on :/

1 answer

1


When you use a style that uses the AppCompat accurate also put all attributes with android:as a prefix, for example:

<style name="ActionBar.Solid.David" parent="@style/Widget.AppCompat.ActionBar">
    <item name="android:titleTextStyle">@style/TitleTextStyle.David</item>
    <item name="titleTextStyle">@style/TitleTextStyle.David</item>
    <item name="background">@drawable/ab_solid_david</item>
    <item name="android:background">@drawable/ab_solid_david</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_david</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_david</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_david</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_david</item>
    <item name="progressBarStyle">@style/ProgressBar.David</item>
    <item name="android:progressBarStyle">@style/ProgressBar.David</item>
</style>

Detail: if you are using minSdk as 11 you do not need to use the AppCompat in your Tyles. In this case, you could leave only the attributes with the prefix android: at the front, removing those that do not have, for example:

<style name="ActionBar.Solid.David" parent="@style/Widget.Holo.ActionBar">
    <item name="android:titleTextStyle">@style/TitleTextStyle.David</item>
    <item name="android:background">@drawable/ab_solid_david</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_david</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_david</item>
    <item name="android:progressBarStyle">@style/ProgressBar.David</item>
</style>
  • I added the items that did not have the prefix "android:", (my minSkdVersion is 11) but when trying to remove "Appcompat" and exchange it for "Holo" Androidstudio did not recognize...

  • @Mukotoshi tested it the first way I mentioned?

  • Yes, I updated the current code... (There are more things in the code, which was generated by http://jgilfelt.github.io/android-actionbarstylegenerator/)

  • @Mukotoshi you put your Activity with this theme on your Androidmanifest?

  • Yes: <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:Theme="@style/Theme.David" > <Activity android:name=".Activity.Principalactivity" android:label="@string/app_name" > <Intent-filter> <action android:name="android.intent.action.MAIN" /> <Category android:name="android.intent.Category.LAUNCHER" /> </Intent-filter> </Activity> </application>

  • @Mukotoshi you extended your Activity to android.support.v7.app.ActionBarActivity ?

  • Actually I extended to Fragmentactivity, because I use Fragmenttabhost with Tabwidgets

  • @Mukotoshi inherited to ActionBarActivityand testing

  • The colors are still black, I don’t understand what might be happening...

  • I was not updating my "Styles" in the "values-v14" folders after I updated the code worked. Could you tell me if I need to use this folder or if I can delete it? (This folder was generated automatically)

  • @Mukotoshi if you want to do something specific to api 14 up, you need to leave this folder up. Otherwise, no

  • Okay, thank you very much. I’ll delete it if I need to create again later.

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.