样式和主题

来源:互联网 发布:龙献文天下数据 编辑:程序博客网 时间:2024/05/29 10:28
之前样式用的迷迷糊糊的,总是直接把别人的直接复制过来,现在是该总结一下了 

1. style


1.1 创建Styles

要为这个View创建一个新的样式,右键它并选择Refactor > Extract > Style。(android studio 无法实现


在 res/values/styles.xml 将生成样式的布局。


1.2 继承 Styles

第一种语法被称为隐式的语法,使用.号作为标记。

   <!-- Base application theme. -->    <style name="Theme.AppCompat.Light.DarkActionBar.AppTheme"          >        <!-- Customize your theme here. -->    </style>点击打开链接

第二种语法通常叫做显式的语法。它使用一个parent属性,其值就是parent style的名称。这里是一个定义名为AppTheme的样式的代码片段:

  <!-- Base application theme. -->    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">        <!-- Customize your theme here. -->    </style>

大多数开发者在继承自己的style时使用隐式的语法,而继承系统style时使用显式的语法。

主题 请参考下面几篇博客

Android从零开始:创建样式和主题

改变support中AlertDialog的样式

通过源码分析,修改AlertDialog按钮的颜色








0 0