Android通知大图标,有没有办法去掉右下角的小图标?

标签 android notifications status

我有一个显示大图标的通知。

有什么方法可以从这个 View 中删除 hive 及以上设备的较小图标吗?

显然还是保留了顶部状态栏的小图标

enter image description here

   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());

最佳答案

在构建通知后添加此代码。

   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”是您构建的通知,

关于Android通知大图标,有没有办法去掉右下角的小图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23949764/

相关文章:

android - 从 3gpp 生成音频图

java - 如何在模块化 Android 应用程序中共享依赖项

android - 如何像 Pinterest 一样在 Android ImageView 中实现对占位符图像的关注?

java - 如何创建不可删除的通知?

linux - "sudo monit status"显示我进程的状态是超时,为什么?

javascript - 将文件从 Javascript 上传到 PHP

android - Gradle lint 现在 lints 发布版本并需要 keystore 密码?

android - NotificationCompat.Builder 类型未定义 setGroup()?

ios - 应用程序存储分配和低存储通知

c - 计算时以百分比显示运行状态