Android Switch

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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值