1

I'm trying to change the color of the ActionBar from the default dark grey to a different color. I used the suggestion from @inclement from a related question here. Here is my code:

ActionBar:
    background_normal: 'white_background.png'
    background_down: 'white_background.png'
    background_color: [51, 102, 255, .5]

The white_background.png is a 8px * 8px white png image.

Doing this changes the ActionBar's background color from dark grey to light grey (not the color I was expecting). I'm guessing this is due to the behavior that @inclement alluded to regarding the background_color having a tinting effect rather than a block color replacement.

As recommended by @AronBordin, I also tried setting the background_normal and background_down to empty strings, but this does not override the tinting behavior.

What is the correct way to replace the background color of the ActionBar?

Community
  • 1
  • 1
Dirty Penguin
  • 4,212
  • 9
  • 45
  • 69

4 Answers4

4

You have to set the background_image with a pure white image first. The correct implementation is:

background_image: 'white-bg.png'
background_color: .3,.3,.3,1
Bill Bridge
  • 821
  • 1
  • 9
  • 30
1

You can use:

    background_normal: ''
    background_down: ''
    background_color: 0, 1, 0, 1

And the background_color will be a rgba color. Take a look here. The color works as a multiplier to the texture, but if no texture is set, the vertex instruction takes the precise color of the Color instruction.

Aron Bordin
  • 436
  • 4
  • 13
  • This results in the same tinting/multiplier effect that I was getting with my code. It appears that setting the `background_normal` and `background_down` to empty strings does not override this tinting behavior. – Dirty Penguin Jun 01 '15 at 11:40
  • just pay attention that `background_color: [51, 102, 255, .5]` doesn't work. All RGBA values must be specified with a number between 0 and 1. 0, 1, 0, 1 – Aron Bordin Jun 01 '15 at 13:57
  • `background_color: 0, 1, 0, 1` for example, is the same that 0, 255, 0 with 100% alpha – Aron Bordin Jun 01 '15 at 13:57
1

This seems to work for me :

#:import hex kivy.utils.get_color_from_hex

    BoxLayout:
        orientation: 'vertical'
        ActionBar:
            background_image: 'assets/images/bg_normal.png'
            background_color: hex('#9C27B0')

The assets/images/bg_normal.png is a 10x10 white png image

Big Zak
  • 1,040
  • 12
  • 17
0

For Kivy 1.10, I think this will work just fine.

background_color: (0.60, 0.07, 0.70, 1)

use RGBA values out of 1, i.e, decimal values