首页 > 其他 > 详细

Theme(主题)

时间:2016-06-14 11:51:52      阅读:137      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!