ActionBar default color

I use the action bar for the top of the screen and there are buttons there. I would like to add an extra sequence of bots at the bottom, but there are too many controls to fit the action bar, so I create a custom view and layout. I am trying to map the color scheme of the hte Action Bar, but I cannot figure out what Android.R.Color is by default for the action bar.

I set up a custom view layout as shown. There seems to be no inline color for light_gray or anything indicating a menu or default color for the action bar.

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@android:color/darker_gray" /> <stroke android:width="1dip" android:color="#333333"/> </shape> 

Screenshot of difference between top and bottom

+4
source share
2 answers

You can view all styles by looking at styles.xml in the Android SDK platforms folder. eg.

<your-sdk-dir>/platforms/android-16/data/res/values/styles.xml

looking at API level 16, this is what I see

 <style name="Widget.ActionBar"> <item name="android:background">@android:drawable/action_bar_background</item> ... 

if this resource is not publicly available, it is best to set the background and footer backgrounds to what you define. you do this by creating a theme in styles.xml and overriding the style of the action bar,

 <style name="Theme" parent="@android:style/Theme.Holo.Light"> <item name="android:actionBarStyle">@style/ActionBar</item> </style> 

now create the actual style of the action bar,

 <style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar"> <item name="android:background">@drawable/my_background</item> </style> 

now assign this style to your application,

 <application ... android:theme="@style/Theme" > ... 
+6
source

I found that I was looking for color values ​​inside xml files. I could not find him. In the end, the dumbest idea was the best:

Print screen emulator and color set in gimp. This exactly matches the color I was looking for.

For me, this answer is really stupid. However, at the end of the day I quickly managed to find value.

0
source

Source: https://habr.com/ru/post/1438975/


All Articles