Android之如何自定义样式和主题
来源:互联网 发布:魔伴windows桌面下载 编辑:程序博客网 时间:2024/05/20 00:14
样式:对某个组件起作用
主题:对整个应用程序或某个Activity起作用
样式:
例:
在values/style.xml中定义
普通定义:
<style name="mystyle">
<item name="android:textColor">@color/mycolor1</item>
<item name="android:textSize">24sp</item>
</style>
继承定义:(类似于Java继承机制,子样式拥有父样式中的的所有定义,
即:使用子样式会把父样式也用上,
而使用父样式只会使用父样式的定义跟子样式没关系)
<style name="mystyle1">
<item name="android:textColor">@color/mycolor2</item>
</style>
<style name="substyle" parent="mystyle1">
<item name="android:textSize">35sp</item>
</style>
自定义主题:
(也支持继承)
在values/style.xml中定义
<style name="mytheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<style name="mytheme1">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">?android:windowFullscreen</item>
</style>
?android:windowFullscreen 表示以获取的返回值作为设置参数
例:对整个应用程序设置:
在AndroidManifest.xml里面配置
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >//设置整个应用程序的主题
......省略
对某个应用程序的某个Activity(一屏)设置主题:
在AndroidManifest.xml里面配置
.....略
<activity
android:name="com.example.androidui.MainActivity"
android:label="@string/app_name"
android:theme="@style/mythem"//对某个Activity设置主题
>
.....略
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
黑屏,无标题,全屏
@android:style/Theme.Dialog 弹出小窗体形式
@android:style/Theme.Wallpaper 使用桌面墙纸
@android:style/Theme.Translucent 半透明效果
@android:style/Theme.Panel 面板样式尽可能小的在中央显示
主题:对整个应用程序或某个Activity起作用
样式:
例:
在values/style.xml中定义
普通定义:
<style name="mystyle">
<item name="android:textColor">@color/mycolor1</item>
<item name="android:textSize">24sp</item>
</style>
继承定义:(类似于Java继承机制,子样式拥有父样式中的的所有定义,
即:使用子样式会把父样式也用上,
而使用父样式只会使用父样式的定义跟子样式没关系)
<style name="mystyle1">
<item name="android:textColor">@color/mycolor2</item>
</style>
<style name="substyle" parent="mystyle1">
<item name="android:textSize">35sp</item>
</style>
自定义主题:
(也支持继承)
在values/style.xml中定义
<style name="mytheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
<style name="mytheme1">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">?android:windowFullscreen</item>
</style>
?android:windowFullscreen 表示以获取的返回值作为设置参数
例:对整个应用程序设置:
在AndroidManifest.xml里面配置
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >//设置整个应用程序的主题
......省略
对某个应用程序的某个Activity(一屏)设置主题:
在AndroidManifest.xml里面配置
.....略
<activity
android:name="com.example.androidui.MainActivity"
android:label="@string/app_name"
android:theme="@style/mythem"//对某个Activity设置主题
>
.....略
3使用系统定义好的主题:
在AndroidManifest.xml里面配置
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
黑屏,无标题,全屏
@android:style/Theme.Dialog 弹出小窗体形式
@android:style/Theme.Wallpaper 使用桌面墙纸
@android:style/Theme.Translucent 半透明效果
@android:style/Theme.Panel 面板样式尽可能小的在中央显示
0 0
- Android之如何自定义样式和主题
- android 之样式和主题
- Android之样式和主题
- 如何自定义visifire图表主题和样式?
- Android开发之:如何使用样式和主题
- Android开发之:如何使用样式和主题
- Android中的自定义主题和样式
- Android代码练习:自定义样式和主题
- Android中使用自定义样式和主题
- android 自定义主题样式
- android 自定义主题样式
- 自定义android主题样式
- android自定义主题样式
- android 自定义主题样式
- 样式和主题&自定义样式和主题
- 样式和主题 + 自定义样式和主题
- Android如何使用样式和主题
- Android主题和样式之系统篇
- ps改变图片色调
- Java学习第十九天
- Throwable类与异常
- MFC中出现错误的解决方法。
- 【Oracle】实现主键自增
- Android之如何自定义样式和主题
- BCB调用FastReport4合并单元格
- C++ 简单实现HTTP GET/POST 请求
- SQL group by分组查询
- Num 33 : 函数递归 [ 全排列 ]
- 无线网络
- elasticsearch中遇到的一些问题以及解决方式
- 后台批量更新安全库存等信息
- Xutils框架