Android Styles / Themes要点整理
来源:互联网 发布:php正则表达式函数 编辑:程序博客网 时间:2024/05/19 15:24
(整理得比较草,用于以后查找)
res/values/
directory of your project. The name of the XML file is arbitrary, but it must use the .xml
extension and be saved in the res/values/
folder.The best place to find properties that apply to a specific View
is the corresponding class reference, which lists all of the supported XML attributes. For example, all of the attributes listed in the table of TextView XML attributescan be used in a style definition for a TextView
element (or one of its subclasses). One of the attributes listed in the reference is android:inputType
, so where you might normally place the android:inputType
attribute in an<EditText>
element, like this:
<EditText android:inputType="number" ... />
R.attr
reference.R.styleable.Theme
.R.style
class.R.style
for Android styles and themes
The R.style
reference, however, is not well documented and does not thoroughly describe the styles, so viewing the actual source code for these styles and themes will give you a better understanding of what style properties each one provides. For a better reference to the Android styles and themes, see the following source code:
- Android Styles (styles.xml) -----也即这里: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
- Android Themes (themes.xml) -----也即这里: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
These files will help you learn through example. For instance, in the Android themes source code, you'll find a declaration for <style name="Theme.Dialog">
. In this definition, you'll see all of the properties that are used to style dialogs that are used by the Android framework.
Theme.Holo
theme (or one of its descendants), which is the default theme when either thetargetSdkVersion
or minSdkVersion
attribute is set to "11"
or greater. For example:<?xml version="1.0" encoding="utf-8"?><resources> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#00FF00</item> <item name="android:typeface">monospace</item> </style></resources>
<style name="CodeFont.Red"> <item name="android:textColor">#FF0000</item> </style>
<TextView style="@style/CodeFont" android:text="@string/hello" />
<application android:theme="@style/CustomTheme">
<activity android:theme="@android:style/Theme.Dialog">
For example, here is the declaration for a custom theme which is simply the standard platforms default light theme. It would go in an XML file under res/values
(typically res/values/styles.xml
):
<style name="LightThemeSelector" parent="android:Theme.Light"> ...</style>
To have this theme use the newer holographic theme when the application is running on Android 3.0 (API Level 11) or higher, you can place an alternative declaration for the theme in an XML file in res/values-v11
, but make the parent theme the holographic theme:
<style name="LightThemeSelector" parent="android:Theme.Holo.Light"> ...</style>
Now use this theme like you would any other, and your application will automatically switch to the holographic theme if running on Android 3.0 or higher.
- Android Styles / Themes要点整理
- Android Styles & Themes
- [转]Android Styles & Themes
- Android Styles and Themes
- android--Styles and Themes
- Android Styles & Themes
- Android - Styles and Themes
- Android-Styles and Themes
- android-Styles and Themes
- Android的Styles和Themes
- android Platform Styles and Themes
- Android中 Styles和Themes
- Android中的Styles and Themes
- Android之Styles and Themes
- Android系统Styles and Themes
- Android之Styles And Themes学习
- Android中Styles、Themes、attrs介绍
- Android API Guides---Styles and Themes
- springMVC初步学习(七)
- 对16进制数处理
- C++不定参数用法实践
- cygwin 软件安装利器 ---apt-cyg
- 【Orientation】详解Android中的屏幕方向
- Android Styles / Themes要点整理
- 转载————————---多态--------------
- oracle 统计信息是什么
- Combinations
- 栈的应用---平衡符号
- 日语N2模拟题
- JButton常用设置
- SAP 表格维护生成器-部分字段不能修改或不能看见
- 怎么用程序实现调用Android手机的拍照功能