码迷,mamicode.com
首页 > 移动开发 > 详细

android的style控制Theme

时间:2015-02-07 01:43:25      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

value-v14就是在API14(4.0)的手机上所使用的Theme(其他版本以此类推)

theme的名字叫做AppTheme,后面写有继承自哪个Theme,如下所示

<style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar">
  <item name="android:windowContentOverlay">@null</item>
  <item name="android:windowNoTitle">true</item>
  <item name="android:textColor">@color/body_text_1</item>
  <item name="android:textColorHighlight">@color/blue_400</item>
  <item name="android:textColorHint">@color/grey_500</item>
  <item name="android:textColorLink">@color/blue_500</item>
  <item name="android:textSize">16sp</item>
  <item name="android:textStyle">normal</item>
</style>

parent还可以设置为这种形式

  <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
  </style>

正如我们所看到的,在Theme中我们可以设置光标的颜色,文字的颜色,hint的颜色等

真实起作用的地方是在manifest.xml文件中. 在这个文件中是这样定义的

<application
  android:name=".HKApplication"
  android:configChanges="locale|keyboard|screenSize|keyboardHidden"
  android:hardwareAccelerated="true"  
  android:icon="@drawable/app_logo"
  android:label="@string/app_name"
  android:logo="@drawable/app_logo"
  android:theme="@style/AppTheme" >

只要在value文件夹的style中定义AppTheme的名字.然后inherict from AppBaseTheme.在不同的value文件夹中有不同的AppBaseTheme文件的定义.

这样就会从根据不同的API去取不同的AppBaseTheme,然后构成AppTheme,设置到程序中.

其实这些东西你自己新建一个工程就会在里面看到注释的,很详细.(这个是value文件夹下的style.xml)技术分享

android的style控制Theme

标签:

原文地址:http://www.cnblogs.com/yiludugufei/p/4278277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!