如何获取Twitter应用程序中的彩色文本和图标?在我的应用程序的颜色显示为灰色和白色..如何改变这? Android Nougat通知栏中的彩色文字和图标
0
A
回答
1
您可以使用您的通知生成器
定制
contentView
要定义自定义通知布局,通过实例化一个膨胀XML布局文件 RemoteViews对象开始。然后,而不是调用诸如setContentTitle()之类的方法,调用setContent()。要在自定义通知中设置 内容详细信息,请使用 RemoteViews中的方法设置视图子项的值:在单独的文件中为通知创建XML布局。您可以使用 使用您希望的任何文件名,但必须使用扩展名.xml在 您的应用程序中,使用RemoteViews方法来定义通知的图标 和文本。通过调用setContent()将此RemoteViews对象放入您的NotificationCompat.Builder中。避免你的RemoteViews对象上设置一个 背景绘制对象,因为你的文字 颜色可能变得不可读。
而且代码如下:
RemoteViews mycontentView = new RemoteViews(getPackageName(), R.layout.notification);
mycontentView.setImageViewResource(R.id.myimage, R.mipmap.ic_launcher);
mycontentView.setTextViewText(R.id.mytitle, "Custom Notification");
NotificationCompat.Builder myBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContent(mycontentView);
Notification myNotification = myBuilder.build();
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.defaults |= Notification.DEFAULT_VIBRATE;
myNotificationManager.notify(1, myNotification);
其中R.layout.notification
是您的自定义布局文件
和布局文件低于
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="64dp"
android:padding="12dp" >
<ImageView
android:src="@mipmap/ic_launcher"
android:id="@+id/myimage"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp" />
<TextView
android:textSize="12dp"
android:textColor="#000"
android:text="Testing"
android:id="@+id/mytitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/myimage"
/>
</RelativeLayout>
我希望它能帮助。
相关问题
- 1. 状态栏中的彩色通知图标和永远在线的屏幕
- 2. 图标没有显示在Android的通知中nougat
- 3. Android颜色通知图标
- 4. Android炫彩通知图片
- 5. 的Android BottomNavigationView色彩图标的颜色
- 6. Android通知图标颜色有时是白色的,有时是多彩的
- 7. 通知栏图标在Android中从FCM变成白色
- 8. 未知的Android通知栏图标 - 这个图标是什么?
- 9. Android:文字彩色全光
- 10. 哪个图标集是android中的通知栏和下拉通知菜单?
- 11. Android - 增量状态栏通知图标
- 12. Android - 通知栏没有小图标
- 13. Android大通知图标 - 接近文字
- 14. 如何更改Android Nougat通知内联回复颜色?
- 15. 如何禁用Android通知栏上的短信通知图标?
- 16. 状态栏和主要通知的单独通知图标
- 17. android - android 5中的白色圆圈通知图标
- 18. 初始通知是彩色的,然后是白盒通知?
- 19. Android通知栏
- 20. 包含文字视图的Android彩色视图
- 21. 与Phonegap生成和PushPlugin Android的白色通知图标
- 22. 在dialogBox中自定义标题栏(彩色,文本,图标等)WinCE 6.0
- 23. Android通知图标
- 24. Android通知图标
- 25. Android通知图标
- 26. 创建带有彩色背景和居中图标的绘图
- 27. Android mipmap图标作为状态(通知)栏图标
- 28. scite:彩色文字
- 29. 通知图标是橙色
- 30. 多个通知与android中的一个状态栏图标