skip to Main Content

I’ve created the project from default template Bottom Navigation Activity. I found that the background color for BottomNavigationView is #2D2D2D for dark theme. I defined it in colors.xml, but I’m not sure that it’s good solution. Is there any pre-defined colors in system(smth like @android:color/theColorThatINeed)? Where can I see all of them?

3

Answers


  1. the best practice is to use colors.xml, and put there all of your colors,
    and then call it like this:

    android:background="@color/red"
    

    there are also system constants for colors, which contains this constants:
    http://developer.android.com/reference/android/R.color.html

    this resources are read only and you can not add to them more constants.

    Login or Signup to reply.
  2. Is there any pre-defined colors in system?

    Yes, there is but it’s limited. These colors are defined in android.R.color. Here are some of them.

    background_dark
    background_light
    black
    darker_gray
    holo_blue_bright
    holo_blue_dark
    holo_blue_light
    holo_green_dark
    holo_green_light
    holo_orange_dark
    holo_orange_light
    holo_purple
    holo_red_dark
    holo_red_light
    transparent
    white
    widget_edittext_dark
    

    To use them:

    android:background="@android:color/background_dark"/>
    
    Login or Signup to reply.
  3. Unfortunately there isn’t a single place to find all the ‘system colours’. You can either find them through documentation, which is usually easy with the material components (which is where BottomNavigationView is from), or by trawling through the source code. For your particular example the colour you’re after is ?attr/colorSurface, which is in the documentation and the source code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search