Android,自定义通知,总是给我白色文本

Android,自定义通知,总是给我白色文本,android,notifications,push-notification,android-notifications,Android,Notifications,Push Notification,Android Notifications,我正在尝试制作一个定制的通知栏,它可以正常工作,但当我在棒棒糖中测试它时,它会显示标题和内容文本以及白色文本,这对kitkat很好,因为通知栏是黑色的,但对棒棒糖不适用 如何将其更改为默认颜色,或者至少检测动作栏的主题,以便生成if语句来更改文本的颜色 我将感谢任何帮助。非常感谢。我不是很确定,但你可以试试这样的: if (android.os.Build.VERSION.SDK_INT > 20) { // I am not sure of this method r

我正在尝试制作一个定制的通知栏,它可以正常工作,但当我在棒棒糖中测试它时,它会显示标题和内容文本以及白色文本,这对kitkat很好,因为通知栏是黑色的,但对棒棒糖不适用

如何将其更改为默认颜色,或者至少检测动作栏的主题,以便生成if语句来更改文本的颜色


我将感谢任何帮助。非常感谢。

我不是很确定,但你可以试试这样的:

if (android.os.Build.VERSION.SDK_INT > 20) {
    // I am not sure of this method
    remoteViews.setTextColor(R.id.text, Color.WHITE);
}

这是为了检测操作系统是否为棒棒糖或更低版本。非常感谢,还有一件事,SDK_INT>20之后是棒棒糖吗?您想更改文本的颜色,然后在if条件块中更改它。。把它改成蓝色或任何其他颜色。20岁以后。。不客气。。如果我的回答对你有帮助,请接受我的回答。你说的“接受”是什么意思?要付支票吗?我已经做了可能的复制品
public void CustomNotification(String strtext) {
        // Using RemoteViews to bind custom layouts into Notification
        RemoteViews remoteViews = new RemoteViews(getPackageName(),
                R.layout.customnotification);

        // Set Notification Title
        String strtitle = getString(R.string.customnotificationtitle);
        // Open NotificationView Class on Notification Click
        Intent intent = new Intent(this, NotificationView.class);
        // Send data to NotificationView Class
        intent.putExtra("title", strtitle);
        intent.putExtra("text", strtext);
        intent.putExtra("String T", "");
        //intent.putExtra("Integer C", 0);

        // Open NotificationView.java Activity
        PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                // Set Icon
                .setSmallIcon(R.drawable.ic_launcher)
                        // Set Ticker Message
                .setTicker(getString(R.string.customnotificationticker))
                        // Dismiss Notification
                .setAutoCancel(true)
                        // Set PendingIntent into Notification
                .setContentIntent(pIntent)
                        // Set RemoteViews into Notification
                .setContent(remoteViews);

        // Locate and set the Image into customnotificationtext.xml ImageViews
        remoteViews.setImageViewResource(R.id.imagenotileft,R.drawable.ic_launcher);
        remoteViews.setImageViewResource(R.id.imagenotiright,R.mipmap.ic_action_chat);

        // Locate and set the Text into customnotificationtext.xml TextViews
        remoteViews.setTextViewText(R.id.title,getString(R.string.customnotificationtitle));
        remoteViews.setTextViewText(R.id.text, strtext);

        // Create Notification Manager
        NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        // Build Notification with Notification Manager
        notificationmanager.notify(0, builder.build());

    }
if (android.os.Build.VERSION.SDK_INT > 20) {
    // I am not sure of this method
    remoteViews.setTextColor(R.id.text, Color.WHITE);
}