2014-11-18 12 views
6

मैं पूछना चाहता था कि .setLargeIcon से अधिसूचना का रंग सेट करने का कोई तरीका है या नहीं? जैसे ही मैं .setSmallIcon और .setLargeIcon दोनों का उपयोग करता हूं, मेरा रंग छोटे आइकन के लिए उपयोग किया जाता है। मैं BigIcon और ऐप आइकन के साथ अपने व्यक्तिगत अधिसूचना आइकन का प्रतिनिधित्व करना चाहता था, जिससे अधिसूचना छोटे आइकन के साथ ट्रिगर हुई थी।एंड्रॉइड .सेट आइकन बड़ा आइकन

उदाहरण:

Bitmap maintenanceIcon = BitmapFactory.decodeResource(getResources(),R.drawable.maintenance); 
      Intent replacePumpIntent = new Intent(this, FoodListActivity.class); 
      PendingIntent replacePumpPendingIntent = PendingIntent.getActivity(this,0,replacePumpIntent, PendingIntent.FLAG_UPDATE_CURRENT); 
      NotificationCompat.Builder maintenanceBuilder = new NotificationCompat.Builder(this) 


        .setLargeIcon(maintenanceIcon) 
        .setSmallIcon(R.drawable.app) 
        .setContentTitle("Maintenance: ") 
        .setColor(getResources().getColor(R.color.alertMaintenance)) 
        .setContentText(Html.fromHtml(getString(R.string.alert_maintenance_message))) 

        .setLights(Color.YELLOW, 500 , 500) 
        .setVibrate(new long[] { 100, 250, 100, 250, 100, 250 }) 
        .setPriority(0x00000001) 
        .setStyle(new NotificationCompat.BigTextStyle() 
          .bigText(Html.fromHtml(getString(R.string.alert_maintenance_message)))) 
        .addAction(R.drawable.ic_arrow_right_black, getString(R.string.alert_maintenance_button_1),replacePumpPendingIntent); 

      NotificationManager maintenanceNotificationManager = 
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
      maintenanceNotificationManager.notify(3, maintenanceBuilder.build()); 

उत्तर

1

इस के अनुसार: https://stackoverflow.com/a/27023679/327011

कोई रास्ता नहीं जब दोनों होने बड़े चिह्न पृष्ठभूमि बदलने के लिए नहीं है। बड़ा आइकन पारदर्शी नहीं होना चाहिए।

2

इस आपको नोटिफिकेशन आइकन

Notification notification = new NotificationCompat.Builder(context) 
    .setSmallIcon(R.mipmap.ic_launcher) 
    .setContentText("Simple description of something meaningful") 
    .setContentTitle("Yo check this out") 
    .setColor(context.getResources() 
      .getColor(R.color.brand_color)) 
    .build(); 

NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); 

manager.notify(SINGLE_NOTIFICATION_ID, notification); 

brand_color is defined as #FF0066CC. 

Source

से धूसर रंग को दूर करने में मदद मिलेगी
संबंधित मुद्दे