android中的Style与Theme
2013-06-11 14:44
246 查看
Android默认情况下提供了一些实用的主题样式,比如说Theme.Dialog可以让你的Activity变成一个窗口风格,而Theme.Light则让你的整个Activity具有白色的背景,而不是黑色那么沉闷。具体使用方法很简单在Androidmanifest.xml文件中对你的Activity节点上加入些代码,如图1所示:
越来越多互联网企业都在Android平台上部署其客户端,为了提升用户体验,这些客户端都做得布局合理而且美观.......Android的Style设计就是提升用户体验的关键之一。Android上的Style分为了两个方面:
1,Theme是针对窗体级别的,改变窗体样式;
2,Style是针对窗体元素级别的,改变指定控件或者Layout的样式。
Android系统的themes.xml和style.xml(位于系统源代码frameworks\base\core\res\res\values\)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。
标签:
AndroidSDK
3.[代码]themes.xml
4.[代码]styles.xml
5.[代码]main.xml跳至
view
source
print?
越来越多互联网企业都在Android平台上部署其客户端,为了提升用户体验,这些客户端都做得布局合理而且美观.......Android的Style设计就是提升用户体验的关键之一。Android上的Style分为了两个方面:
1,Theme是针对窗体级别的,改变窗体样式;
2,Style是针对窗体元素级别的,改变指定控件或者Layout的样式。
Android系统的themes.xml和style.xml(位于系统源代码frameworks\base\core\res\res\values\)包含了很多系统定义好的style,建议在里面挑个合适的,然后再继承修改。
标签:
AndroidSDK
代码片段(5)[全屏查看所有代码]
1.[图片]tu1.jpg
2.[图片]效果图.gif
3.[代码]themes.xml
01 | <!-- Windowattributes--> |
02 | < item name = "windowBackground" >@android:drawable/screen_background_dark</ item > |
03 | < item name = "windowFrame" >@null</ item > |
04 | < item name = "windowNoTitle" >false</ item > |
05 | < item name = "windowFullscreen" >false</ item > |
06 | < item name = "windowIsFloating" >false</ item > |
07 | < item name = "windowContentOverlay" >@android:drawable/title_bar_shadow</ item > |
08 | < item name = "windowTitleStyle" >@android:style/WindowTitle</ item > |
09 | < item name = "windowTitleSize" >25dip</ item > |
10 | < item name = "windowTitleBackgroundStyle" >@android:style/WindowTitleBackground</ item > |
11 | < item name = "android:windowAnimationStyle" >@android:style/Animation.Activity</ item > |
4.[代码]styles.xml
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | < resources > |
03 | < style name = "TextView" > |
04 | < item name = "android:textSize" >18sp</ item > |
05 | < item name = "android:textColor" >#008</ item > |
06 | < item name = "android:shadowColor" >@android:color/black</ item > |
07 | < item name = "android:shadowRadius" >2.0</ item > |
08 | </ style > |
09 |
10 | < style name = "EditText" > |
11 | < item name = "android:shadowColor" >@android:color/black</ item > |
12 | < item name = "android:shadowRadius" >1.0</ item > |
13 | < item name = "android:background" >@android:drawable/btn_default</ item > |
14 | < item name = "android:textAppearance" >?android:attr/textAppearanceMedium</ item > |
15 | </ style > |
16 |
17 | < style name = "Button" > |
18 | < item name = "android:background" >@android:drawable/edit_text</ item > |
19 | < item name = "android:textAppearance" >?android:attr/textAppearanceMedium</ item > |
20 | </ style > |
21 | </ resources > |
5.[代码]main.xml跳至[3][4][5][全屏预览]
viewsource
01 | <? xml version = "1.0" encoding = "utf-8" ?> |
02 | < LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" |
03 | android:orientation = "vertical" android:layout_width = "fill_parent" |
04 | android:layout_height = "fill_parent" > |
05 | < TextView android:layout_width = "fill_parent" |
06 | android:layout_height = "wrap_content" android:text = "@string/hello" |
07 | style = "@style/TextView" /> |
08 | < EditText android:id = "@+id/EditText01" android:layout_height = "wrap_content" |
09 | style = "@style/EditText" android:layout_width = "fill_parent" |
10 | android:text = "类似Button的EditText" ></ EditText > |
11 | < EditText android:id = "@+id/EditText02" android:layout_height = "wrap_content" |
12 | android:layout_width = "fill_parent" android:text = "普通的EditText" ></ EditText > |
13 | < Button android:id = "@+id/Button01" android:layout_height = "wrap_content" |
14 | style = "@style/Button" android:layout_width = "fill_parent" android:text = "类似EditText的Button" ></ Button > |
15 | </ LinearLayout > |
相关文章推荐
- Android 避免APP启动闪黑屏(Theme和Style)
- Android:Theme 和 style
- Android 风格与主题(style and theme)
- android-样式和主题(style&theme)
- android的样式(style)与主题(theme)
- Android入门第十六篇之Style与Theme
- Android总结之style(样式)和Theme(主题)
- 20.(转)Android的样式(Style)和主题(Theme)
- Android的Style和Theme 译文
- Android 避免APP启动闪黑屏(Theme和Style)
- android之风格与主题(style与theme)
- Android风格与主题(style and theme)
- Applying Styles and Themes - 应用Style和Theme - Android官方文档中文翻译
- Android基础之Style Theme
- 基于android样式与主题(style&theme)的详解
- Android入门第十六篇之Style与Theme
- Android 避免APP启动闪黑屏的解决办法(Theme和Style)
- Android中Style和Theme的使用
- (4.1.20)android的样式(style)与主题(theme)
- android的样式(style)与主题(theme)