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,建议在里面挑个合适的,然后再继承修改。

 
标签: Android SDK
 

代码片段(5)[全屏查看所有代码]

1. [图片] tu1.jpg

2. [图片] 效果图.gif

3. [代码]themes.xml

1
2
3
4
5
6
7
8
9
10
11
<!-- Window attributes -->   
<item name="windowBackground">@android:drawable/screen_background_dark</item>   
<item name="windowFrame">@null</item>   
<item name="windowNoTitle">false</item>   
<item name="windowFullscreen">false</item>   
<item name="windowIsFloating">false</item>   
<item name="windowContentOverlay">@android:drawable/title_bar_shadow</item>   
<item name="windowTitleStyle">@android:style/WindowTitle</item>   
<item name="windowTitleSize">25dip</item>   
<item name="windowTitleBackgroundStyle">@android:style/WindowTitleBackground</item>   
<item name="android:windowAnimationStyle">@android:style/Animation.Activity</item>

4. [代码]styles.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<resources>
 <style name="TextView">
  <item name="android:textSize">18sp</item>
  <item name="android:textColor">#008</item>
  <item name="android:shadowColor">@android:color/black</item>
  <item name="android:shadowRadius">2.0</item>
 </style>
    
 <style name="EditText">
  <item name="android:shadowColor">@android:color/black</item>
  <item name="android:shadowRadius">1.0</item>
  <item name="android:background">@android:drawable/btn_default</item>
  <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
 </style>
    
    <style name="Button">
        <item name="android:background">@android:drawable/edit_text</item>
        <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
    </style>
</resources>

5. [代码]main.xml

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical" android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  
    <TextView android:layout_width="fill_parent"  
        android:layout_height="wrap_content" android:text="@string/hello"  
        style="@style/TextView" />  
    <EditText android:id="@+id/EditText01" android:layout_height="wrap_content"  
        style="@style/EditText" android:layout_width="fill_parent"  
        android:text="类似Button的EditText"></EditText>  
    <EditText android:id="@+id/EditText02" android:layout_height="wrap_content"  
        android:layout_width="fill_parent" android:text="普通的EditText"></EditText>  
    <Button android:id="@+id/Button01" android:layout_height="wrap_content"  
        style="@style/Button" android:layout_width="fill_parent" android:text="类似EditText的Button"></Button>  
</LinearLayout>
 
from:http://www.oschina.net/code/snippet_166763_6509

【转】android中的Style与Theme的更多相关文章

  1. Android 中的style和Theme的使用

    说明 style和theme的定义是为了改变原有系统设定的默认窗体.字体.背景色.格式等风格而使用.其本质就是系统属性的集合.本篇主要介绍android中的style和theme的具体用法. styl ...

  2. 【转】说说Android中的style和theme

    最近在做软件从2.3到4.0的改变的一些工作,其中涉及了一些style和theme相关的东西.上网上查了一些东西,这个一并说说.关于android中style和theme的基本使用,这里就不再赘述了, ...

  3. Android中的 style 和 theme

    通过设置 view 控件的属性,达到设置android UI的目的,如果某些 属性值复用率很高,可以考虑将属性单独声明在 style中,这样就可以达到复用的效果. 一.style Style 概念:A ...

  4. android中的style部分属性值介绍

    转自:http://blog.sina.com.cn/s/blog_70c759fd01013phv.html Android平台定义的主题样式: android:theme="@andro ...

  5. android中的style部分属性值介绍 --zz

    Android平台定义的主题样式: android:theme="@android:style/Theme.Dialog"   将一个Activity显示为对话框模式 •andro ...

  6. ArcGIS Runtime SDK for Android中SimpleFillSymbol.Style样式

    SimpleFillSymbol.Style样式枚举共8种: 1.BACKWARD_DIAGONAL 反对角线填充 2.CROSS 交叉线填充 3.DIAGONAL_CROSS 前后对角线填充 4.F ...

  7. Android中Style和Theme的使用

    Style: Style是View中一些属性的集合,包括height,padding,font color,background等等,Style单独定义在xml文件中,类似与web页面中css的角色, ...

  8. Android中theme.xml与style.xml的区别

    一.相同点 两者的定义相同.继承方式也相同 <?xml version="1.0" encoding="utf-8"?> <resources ...

  9. Android中style和theme的区别

    在学习Xamarin android的过程中,最先开始学习的还是熟练掌握android的六大布局-LinearLayout .RelativeLayout.TableLayout.FrameLayou ...

随机推荐

  1. qsor快排序以及cmp函数

    void qsort(void*base,size_t num,size_t width,int(__cdecl*compare)(const void*,const void*)); 各参数:1 待 ...

  2. 1.5 GO json转Map

    使用GO将show slave status查询返回的json串转为Map类型 package main import ( "encoding/json" "fmt&qu ...

  3. linux下pid命令

    ps aux | grep tomcat|  awk '{if(NR==1)print $2}' Linux:批量修改分隔符(awk.BEGIN.FS.OFS.print.tr命令) 批量修改文件的分 ...

  4. Checkstyle的配置详解

    Checkstyle是一款检查java程序代码样式的工具,可以有效的帮助我们检视代码以便更好的遵循代码编写标准,特别适用于小组开发时彼此间的样式规范和统一.Checkstyle提供了高可配置性,以便适 ...

  5. Unity Scene Screen.resolutions 分辨率列表

    Screen.resolutions 分辨率列表(安卓平台试了不能用此方法,最好用宏定义判断一下平台) C# => public static Resolution[] resolutions; ...

  6. PlayMaker 对 PlayMakerFSM 里变量的操作

    HutongGames.PlayMaker; //需要引用这个命名空间 红色的字体是对变量的操作,其他的没啥关系. #region 判断为 PlayMakerFSM 组件时 if (behaviour ...

  7. Linux下wget下载软件小技巧以及安装jdk、tomcat与ftp服务器

    一.ftp的安装 装个ftp搞了一下午,感觉以前没那么麻烦的呀,结果到晚上才发现是实验室网的问题,换连手机的热点马上可以了,真是尴尬,把基本安装步骤记录一下: 1.检查安装vsftpd软件 使用如下命 ...

  8. LeetCode 887.鸡蛋掉落(C++)

    每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去. 你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落下的 ...

  9. Linux下的NFS快速配置教程与安全策略

    [51CTO专稿]在Linux下实现文件共享有多种方式,NFS就是其中之一.网络文件系统(NFS)协议是由Sun MicroSystem在20世纪80年代为了提供对共享文件的远程访问而设计和实现的.该 ...

  10. PHP的htmlspecialchars、strip_tags、addslashes解释

    第一个函数:strip_tags,去掉 HTML 及 PHP 的标记 注意:本函数可去掉字串中包含的任何 HTML 及 PHP 的标记字串.若是字串的 HTML 及 PHP 标签原来就有错,例如少了大 ...