Android中theme的用法
来源:互联网 发布:刘亦婷混的好吗知乎 编辑:程序博客网 时间:2024/04/30 22:20
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的使用
- 大数相加 相乘
- 系统自带样式Android:theme
- 线程间操作无效:从不是创建控件“XX”的线程访问它
- 分组统计
- 字符串输入输出cin.get的用法
- Android中theme的用法
- java编码问题
- linux port ip
- 寻找链表倒数第K个结点
- 用Javascript编写Chrome浏览器插件
- RMQ(Range Minimum/Maximum Query)算法(nyist119)
- Apache Ant对决Make:实战Java构建工具
- 【GitHub】 github如何使用
- 动态规划算法的理解