[android] 安卓自定义样式和主题
2023-02-18 15:47:42 时间
简单练习自定义样式和主题,样式是加在View上,主题是加在Application或者Activity上
styles.xml
<?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 自定义样式 --> <style name="MyFont"> <item name="android:textColor">#ff0000</item> <item name="android:textSize">40sp</item> </style> <style name="MyFontSon" parent="@style/MyFont"> <item name="android:textSize">30sp</item> </style> <!-- 自定义主题 --> <style name="MyTheme"> <item name='android:windowNoTitle'>true</item> <item name="android:background">#ffffff</item> </style> </resources>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView style="@style/MyFont" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="样式和主题" /> <TextView style="@style/MyFontSon" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="样式和主题" /> </LinearLayout>
Manifest.xml
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="ss" android:theme="@style/MyTheme" >
相关文章
- 【架构师(第三十七篇)】 服务端开发之后端框架与数据库技术选型
- 【架构师(第三十八篇)】 服务端开发之本地安装最新版 MySQL 数据库
- 【架构师(第三十九篇)】 服务端开发之连接 MySQL 数据库
- 【架构师(第四十一篇)】 服务端开发之安装并连接 Redis数据库
- MySQL的date_format()和str_to_date()
- mysql查询语句left join和right join问题(日常工作遇到问题总结-仅供个人学习)
- Mac安装Navicat for MySQL(数据库管理工具)教程支持M2M1
- 【MySQL】深入分析 锁机制(一)行锁 加锁规则 之 等值查询
- MYSQL数据库-索引
- MYSQL数据库-复合查询
- MYSQL数据库-内外连接
- [android] 安卓消息推送的几种实现方式
- [android] 安卓进程优先级&为什么使用服务
- MySQL 日志之 binlog 格式 → 关于 MySQL 默认隔离级别的探讨
- [android] 安卓自定义样式和主题
- [javaEE] 开源数据库连接池
- [javaEE] 数据库连接池和动态代理
- [android] 安卓消息推送的几种实现方式
- [android] 安卓进程优先级&为什么使用服务
- Mysql join left查询无法命中索引一例