Android(安卓)自定义Notification字体颜色适配
16lz
2021-01-26
不同系统的通知背景色不同,使用自定义通知使用透明背景色,字体颜色跟随系统的Notification中文字的样式。
在res的values目录下定义styles.xml文件如下:
<?xml version="1.0" encoding="utf-8"?><resources> <style name="NotificationInfo" parent="android:TextAppearance.StatusBar.EventContent" /> <style name="NotificationTitle" parent="android:TextAppearance.StatusBar.EventContent.Title" />resources>
在res的values-v21目录下定义styles.xml文件如下:
<?xml version="1.0" encoding="utf-8"?><resources> <style name="NotificationInfo" parent="android:TextAppearance.Material.Notification.Info" /> <style name="NotificationTitle" parent="android:TextAppearance.Material.Notification.Title" />resources>
自定义通知布局文件调用:
"wrap_content" android:layout_height="wrap_content" android:text="@string/notification_title" style="@style/NotificationTitle" />"@+id/content_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/toast_ble_disconnected_1" style="@style/NotificationInfo" />
更多相关文章
- 系统定义弹窗以及自定义弹窗
- Android之CheckBox(多选按钮)
- Mac OS 上配置Android(安卓)studio的真机调试环境
- Android(安卓)Fragment学习笔记(一)
- Android(安卓)boot.img 结构
- 解决Android(安卓)studio 2.3升级到Android(安卓)studio 3.0 后a
- Android(安卓)Studio添加so文件并打包到APK的lib文件夹中
- 将tensorflow训练好的模型移植到Android(安卓)(MNIST手写数字识
- 创建android phonegap项目