android自定义style实现2
来源:互联网 发布:win32 sdk编程 编辑:程序博客网 时间:2024/06/06 06:36
1、在res/values/styles定义style:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" parent="android:Theme.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backward-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style> <style name="CodeFont" parent="@android:style/TextAppearance.Medium"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:typeface">monospace</item> </style> <style name="CodeFont.Red"> <item name="android:textColor">#00FF00</item> </style> <style name="CodeFont.Red.Big"> <item name="android:textSize">30sp</item> </style> <color name="custom_theme_color">#b0b0ff</color> <!-- 表示Application的一个主题 --> <style name="CustomTheme" parent="android:Theme.Light"> <item name="android:windowBackground">@color/custom_theme_color</item> <item name="android:colorBackground">@color/custom_theme_color</item> </style></resources>
2、在布局文件中引用主题
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView style="@style/CodeFont.Red.Big" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /></RelativeLayout>
0 0
- android自定义style实现2
- android自定义style
- Android--自定义Style
- Android自定义Style
- Android开发自定义Style
- Android自定义Theme&style
- android自定义style
- android自定义style
- Android自定义Style
- android自定义style
- android如何自定义style
- android自定义dialog style
- android 基础 自定义style
- Android 自定义style
- Android自定义对话框实现以及style的应用
- android自定义style主题样式
- Android 自定义控件外观style
- Decalre-style Android自定义属性
- HBase总结(十八)Hbase rowkey设计一
- 大师放大师傅撒旦法的萨芬
- ContOS如何使用本地cdrom作为yum源
- 遍历map的四种方法
- twemproxy安装与配置
- android自定义style实现2
- Android解析XML文件
- MySQL自定义函数计算年龄
- 黑马程序员——java基础——IO流(续)
- TergetMarker-2-设计初步准备工作
- android开发两种退出程序方式(killProcess,System.exit)
- HBase的rowkey设计
- poj 3613 Cow Relays 经L边的最短路
- 飘逸的python - 使用图像匹配SIFT算法进行LOGO检测