0

我似乎无法有效地设置我的通知样式。我有一个在前台服务中运行的通知,我不想创建自定义通知,因为它没有像我想要的那样优雅地呈现。我似乎无法像在文档中那样创建它。 像这个

该通知是一个活动的呼叫通知,它需要在用户可能拥有的其他通知之间尽可能独特。

// styling notification
    Spannable spannable = new SpannableString(input);
    spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, input.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.addLine(spannable);
    inboxStyle.addLine(getNotificationContent(getApplicationContext(), type).text);

Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
            .setContentTitle(Build.VERSION.SDK_INT == 23 ? getApplicationContext().getResources().getString(R.string.app_name) : "")
            // conditional Content and Icon depending on the @IncallNotificationType
            .setContentText(
                    type == NotificationHandler.InCallNotificationType.NORMAL
                            ? input
                            : getNotificationContent(getApplicationContext(), type).text)
            .setSmallIcon(
                    type == NotificationHandler.InCallNotificationType.NORMAL
                            ? android.R.drawable.ic_menu_call
                            : getNotificationContent(getApplicationContext(), type).resId)
            .setGroup("false")
            .setPriority(Notification.PRIORITY_MAX)
            .setFullScreenIntent(fullScreenPendingIntent, true)
            .setColorized(true)
            .setUsesChronometer(true).setWhen(timeStarted)
            .setStyle(inboxStyle)
            .setColor(ContextCompat.getColor(getApplicationContext(), R.color.accent))
            .addAction(R.drawable.ic_general_loud, "speaker", speakerPendingIntent)
            .addAction(R.drawable.selector_mute, muteButtonText, mutePendingIntent)
            .addAction(R.drawable.ic_general_hold, "end call", endCallPendingIntent)
            .build();

这是我的通知就 在这里

我想要做的是减少从 AppName 到“正在进行呼叫”的间距,如果可能的话,更改按钮的背景。所以,我想设置这个通知的样式,但我不能使用自定义的。

4

0 回答 0