0

I make the notification bar and I wanted to have a big icon near text

I do not do the battery just gave this image as an example.

For Example: http://i45.tinypic.com/23hu5xd.png

Red circle = icon which is always visible. Blue circle = icon that is visible only when you expand.

How do I make such a big icon in the notification? (Blue Circle)

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
Defuzer
  • 119
  • 2
  • 14

2 Answers2

1

You have to use your own layout for that.

This is deprecated, because now you should use builder for everything, but sometimes you just need to do something special.

    String ns = Context.NOTIFICATION_SERVICE;
    mNotificationManager = (NotificationManager) ctx.getSystemService(ns);

    int icon = R.drawable.icon;
    CharSequence tickerText = "Ticker Text";
    long when = System.currentTimeMillis();

    notification = new Notification(icon, tickerText, when);
    String packageName = ctx.getPackageName();
    contentView = new RemoteViews(packageName, R.layout.notificationlayout);
    notification.contentView = contentView;
    contentView.setTextViewText(R.id.textView1, "Text");
    Intent notificationIntent = new Intent(ctx, TargetActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
    notification.contentIntent = contentIntent;


    mNotificationManager.notify(NOTIFICATION_ID, notification);
Martin Rajniak
  • 630
  • 8
  • 26
1

You can create a custom notification using remote views. In such a remote view you have a degree of freedom to design the layout of your notification, but would advise you to follow the android guidelines on the design.

You can find detailed information on how to create the expanded notification views here.

Gan
  • 1,349
  • 2
  • 10
  • 27