本文介绍了Android通知大图标,是否可以删除右下角的小图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一条显示大图标的通知.
I have a notification that displays a largeicon.
是否可以从此视图中删除蜂窝及以上设备中的较小图标?
Is there any way to remove the smaller icon from honeycomb and above devices from this view?
显然,顶部状态栏上仍然保留着小图标
Obviously still keeping the small icon for the top status bar
NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
// Set required fields, including the small icon, the
// notification title, and text.
.setSmallIcon(R.drawable.ic_notify_status_new)
.setContentTitle(title)
.setContentText(text)
// All fields below this line are optional.
// Use a default priority (recognized on devices running Android
// 4.1 or later)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Provide a large icon, shown with the notification in the
// notification drawer on devices running Android 3.0 or later.
.setLargeIcon(picture)
.setContentIntent(
PendingIntent.getActivity(
context,
0,
notiIntent,
PendingIntent.FLAG_UPDATE_CURRENT)
);
builder = getNotiSettings(builder);
notify(context, builder.build());
推荐答案
在构建通知后添加此代码.
Add this code after you build the notification.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int smallIconViewId = getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());
if (smallIconViewId != 0) {
if (notif.contentIntent != null)
notif.contentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
if (notif.headsUpContentView != null)
notif.headsUpContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
if (notif.bigContentView != null)
notif.bigContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
}
}
其中"notif"是您的内置通知,
where "notif" is your built notification,
这篇关于Android通知大图标,是否可以删除右下角的小图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!