Android 系统源码网址 :http://aospxref.com/
themes_materials.xml
<item name="switchStyle">@style/Widget.Material.CompoundButton.Switch</item>
style_material.xml
<style name="Widget.Material.CompoundButton.Switch">
654 <item name="track">@drawable/switch_track_material</item>
655 <item name="thumb">@drawable/switch_thumb_material_anim</item>
656 <item name="switchTextAppearance">@style/TextAppearance.Material.Widget.Switch</item>
657 <item name="textOn">@string/capital_on</item>
658 <item name="textOff">@string/capital_off</item>
659 <item name="background">@drawable/control_background_40dp_material</item>
660 <item name="showText">false</item>
661 </style>
xref: /frameworks/base/core/res/res/drawable/switch_track_material.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
18 <item android:gravity="center_vertical|fill_horizontal"
19 android:start="4dp"
20 android:end="4dp">
21 <shape android:shape="rectangle"
22 android:tint="@color/switch_track_material">
23 <corners android:radius="7dp" />
24 <solid android:color="@color/white_disabled_material" />
25 <size android:height="14dp" />
26 </shape>
27 </item>
28 </layer-list>
xref: /frameworks/base/core/res/res/color/switch_track_material.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
18 <item android:state_enabled="false"
19 android:color="?attr/colorForeground"
20 android:alpha="?attr/disabledAlpha" />
21 <item android:state_checked="true"
22 android:color="?attr/colorControlActivated" />
23 <item android:color="?attr/colorForeground" />
24 </selector>
themes_material.xml
<style name="Theme.Material.Light" parent="Theme.Light">
418 <item name="colorForeground">@color/foreground_material_light</item>
419 <item name="colorForegroundInverse">@color/foreground_material_dark</item>
420 <item name="colorBackground">@color/background_material_light</item>
421 <item name="colorBackgroundFloating">@color/background_floating_material_light</item>
422 <item name="colorBackgroundCacheHint">@color/background_cache_hint_selector_material_light</item>
423 <item name="disabledAlpha">@dimen/disabled_alpha_material_light</item>
424 <item name="primaryContentAlpha">@dimen/primary_content_alpha_material_light</item>
425 <item name="secondaryContentAlpha">@dimen/secondary_content_alpha_material_light</item>
426 <item name="backgroundDimAmount">0.6</item>
427 <item name="colorError">@color/error_color_material_light</item>
428 <item name="colorPopupBackground">?attr/colorBackground</item>
429 <item name="colorListDivider">?attr/colorForeground</item>
430 <item name="opacityListDivider">@color/list_divider_opacity_material</item>
xref: /frameworks/base/core/res/res/values/colors_material.xml
<resources>
19 <color name="foreground_material_dark">@color/white</color>
20 <color name="foreground_material_light">@color/black</color>
778 <item name="colorAccent">@color/accent_material_light</item>
42 <color name="accent_material_light">@color/material_deep_teal_500</color>
43 <color name="accent_material_dark">@color/material_deep_teal_200</color>
98 <color name="material_deep_teal_200">#ff80cbc4</color>
100 <color name="material_deep_teal_500">#ff008577</color>
xref: /frameworks/base/core/res/res/values/themes_material.xml
50 <item name="disabledAlpha">@dimen/disabled_alpha_material_dark</item>
xref: /frameworks/base/core/res/res/values/colors_material.xml
74 <item name="disabled_alpha_material_light" format="float" type="dimen">0.26</item>
75 <item name="disabled_alpha_material_dark" format="float" type="dimen">0.30</item>