Android 中的Theme和Style使用,还是比较简单的。
1、 首先在res/values/styles.xml的resource中定义三个样式,分别为:
然后在res/layout文件下的activity_main.xml中的控件中引用刚才定义的Style。
android:id= "@+id/textView1" style= "@style/TextView" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "@string/hello_world" />
|
2、Android的Theme的使用
首先在res/values/themes.xml中定义Theme。
<?xml version= "1.0" encoding= "utf-8" ?> "http://schemas.android.com/apk/res/android" >
|
然后在AndroidManifest.xml中使用刚才定义的主题。
只要定义application的android:theme属性为style/Theme即可。
android:allowBackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/Theme" > android:name= "com.example.themedemo.MainActivity" android:label= "@string/app_name" >
"android.intent.action.MAIN" /> "android.intent.category.LAUNCHER" />
|
也可以用setTheme(R.style.Theme)来调用主题。效果图就不上传了。
本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/archive/2013/03/14/2959164.html,如需转载请自行联系原作者
- 自定义TabActivity,TabActivity的美化
- android4.0自定义标题报错 -----断点记录
- Android 自定义progressDialog
- 在android里面使用自定义字体
- android 发送自定义广播以及接收自定义广播
- android中自定义进度条风格
随机推荐
-
android的socket开发注意事项
-
Android学习资源-retrofit,eventBus,butter
-
Android(安卓)自动化测试
-
寻找android中的设计模式(一)
-
Android studio连接Bmob云数据库教程
-
使用eclipse创建android工程时得到警告
-
《Android》Lesson09-Acitivity的四种启
-
【android】LayoutInflater.inflate方法
-
Android 四大组件,五大存储,六大布局
-
Android Studio打包Signed APK 碰到的一