Android中theme的用法
来源:互联网 发布:windows管理工具 编辑:程序博客网 时间:2024/05/21 06:40
Theme在android的可以采用如下两种办法 :
一,在AndroidManifest.xml文件中,对Activity元素添加andorid:theme属性 ,如文中红色部分。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mike.lei.shen"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
二 ,在java代码中设置 Theme。
package mike.lei.shen;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TextView;
public class TestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
this.setTheme(android.R.style.Theme_Light);
super.onCreate(savedInstanceState);
//this.setTheme(android.R.style.Theme_Light);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.TxtHello);
tv.setText("screen with Light theme!");
}
}
注意,红色代码的位置很重要,API中建议在setContentView之前调用,但在android2.3中是没有用的(其他平台可能也有这个问题)
必须在 super.onCreate(savedInstanceState)之前调用。
两种方法的调用效果图:
- Android中theme的用法
- Android中theme的用法
- android的theme的用法
- Android中的style和theme的用法
- Android 下style和theme的用法
- StylesheetTheme, Theme的用法
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- Android中Theme和Style的应用
- Android中Style和Theme的使用
- android 中 style和theme的区别
- Android manifest中theme的配置
- Android中Theme和Style的使用
- Android 中Theme的使用随笔
- Android中Style和Theme的使用
- Android中Style和Theme的使用
- IE6的window.location.href问题
- 视图 两表联合 查询 id 求和需求
- 彻底理解spring的定制任务(scheduling)
- C#格式化数值结果表
- Java深度理解——Java字节代码的操纵
- Android中theme的用法
- 圣诞的礼物
- 有关Silverlight 4的浏览器支持情况和平台部件
- 正则表达式30分钟入门教程
- 关于JS Cookie的一点点摘抄
- 资源文件显示错误都可以从编绎资源文件的临时文件中找到原因
- android 结构简介
- 利用securecrt在linux与windows之间传输文件
- 记2个月来,我在Csdn 掀起的微软面试风暴