码迷,mamicode.com
首页 > 其他好文 > 详细

Theme(主题)

时间:2016-06-14 11:52:43      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:

Theme简介

一个或者多个属性应用到整个屏幕;theme是作为一个属性被用到Manifest文件当中。

<activity

android:name="CustomTheme"

android:label="@string/app_name"

android:theme="@style/CustomTheme" >

</activity>

 

2)定义一个Style

<style name="myTheme">

<item name="android:windowNoTitle">true</item>

<item name="android:windowBackground">@drawable/init</item>

<item name="android:panelColorBackground">#33a</item>

<item name="android:panelColorForeground">#66a</item>

<item name="android:textSize">18sp</item>

<item name="android:textColor">?android:panelColorBackground</item>

<item name="android:textStyle">bold</item>

<item name="android:textColorLink">#fbb</item> 

</style>

/*  @:表示引用的资源已经在项目中或Framework 里定义了

*  ?:表示应用的资源在当前的Theme中

*/

 

3)使用自定义Theme

①、在AndroidManifest.xml文件中设置Theme应用于整个工程。

<application android:theme="@style/CustomTheme">

// Theme应用当前Activity

<activity android:theme="@android:style/Theme.Dialog" >

… …

②、代码中设置Theme          

protected void onCreate(Bundle savedInstanceState) { 

super.onCreate(savedInstanceState) ; 

setTheme(android.R.style.myTheme) ;

setContentView(R.layout.linear_layout_3) ;

}

Theme(主题)

标签:

原文地址:http://www.cnblogs.com/GGGirl/p/5583347.html

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