I am currently digging through the Google IO 2019 source code and there is one thing I can't figure out where it comes from: the color of the hamburger menu icon.
Here's a screenshot of the preview of mobile\src\main\res\layout\fragment_codelabs.xml
(source link):
And here is a zoom-in of the hamburger menu icon, one can easily see that it's at least not black:
The image source is @drawable/ic_menu
:
The source code of @drawable/ic_menu
(mobile\src\main\res\drawable\ic_menu.xml
) (source link) is
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?colorControlNormal">
<path
android:fillColor="#FF000000"
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z" />
</vector>
So here the fillColor
is specified as #FF000000
which is 100 % black and opaque (alpha FF). Yet the hamburger menu icon isn't displayed in black. So, where is the color that the hamburger menu icon is displayed in actually coming from?
I tried to dig deeper into the styles, most likely it comes from default parameter of one of the parent of Activity theme. I'll try to show how I found it.
\mobile\src\main\AndroidManifest.xml
file, all Activities are inherited from android:theme="@style/AppTheme"
<style name="AppTheme" parent="Base.AppTheme" />
<style name="Base.AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<style name="Theme.MaterialComponents.DayNight.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar"/>
<style name="Theme.MaterialComponents.Light" parent="Base.Theme.MaterialComponents.Light"/>
<style name="Base.Theme.MaterialComponents.Light" parent="Base.V14.Theme.MaterialComponents.Light"/>
<style name="Base.V14.Theme.MaterialComponents.Light" parent="Base.V14.Theme.MaterialComponents.Light.Bridge">
<style name="Base.V14.Theme.MaterialComponents.Light.Bridge" parent="Platform.MaterialComponents.Light">
<style name="Platform.MaterialComponents.Light" parent="Theme.AppCompat.Light"/>
<style name="Theme.AppCompat.Light" parent="Base.Theme.AppCompat.Light"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
<style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
<style name="Base.V26.Theme.AppCompat.Light" parent="Base.V23.Theme.AppCompat.Light">
<style name="Base.V23.Theme.AppCompat.Light" parent="Base.V22.Theme.AppCompat.Light">
<style name="Base.V22.Theme.AppCompat.Light" parent="Base.V21.Theme.AppCompat.Light">
<style name="Base.V21.Theme.AppCompat.Light" parent="Base.V7.Theme.AppCompat.Light">
<item name="android:colorControlNormal">?attr/colorControlNormal</item>
, we need to go deeper.<style name="Base.V7.Theme.AppCompat.Light" parent="Platform.AppCompat.Light">
<item name="colorControlNormal">?android:attr/textColorSecondary</item>
:)<style name="Theme.Material.Light" parent="Theme.Light">
<item name="textColorSecondary">@color/text_color_secondary</item>
text_color_secondary.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:alpha="?attr/disabledAlpha"
android:color="?attr/colorForeground"/>
<item android:alpha="?attr/secondaryContentAlpha"
android:color="?attr/colorForeground"/>
</selector>
<item name="colorForeground">@color/foreground_material_light</item>
colors_material.xml
it is <color name="foreground_material_light">@color/black</color>
<item name="secondary_content_alpha_material_light" format="float" type="dimen">0.54</item>
So, to put it simply: the color of a menu icon is default theme black with alpha 0.54