lim*_*lim 5 android vertical-alignment android-notifications
我想在通知抽屉中为我的应用程序设置通知,但只有一个标题(没有正文),这意味着 - 只有一行通知,应该与应用程序图标垂直对齐.
例如,在下面的通知中,我只想保持"Ringer shushed'tr1 19:16"标题,使用相同的字体大小,但垂直居中于左侧的应用程序图标.

这是我创建通知的代码:
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent deleteIntent = PendingIntent.getService(context, 0,
new Intent(context, GCMIntentService.class)
.setAction(IntentConsts.ACTION_CLEAR_MESSAGE_COUNT), PendingIntent.FLAG_CANCEL_CURRENT);
manager.notify(MMConfig.NTF_ID_GCM, new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.push_icon)
.setContentTitle("My title")
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentIntent(contentIntent)
.setDeleteIntent(deleteIntent)
.build());
Run Code Online (Sandbox Code Playgroud)
现在我成功创建了仅包含标题的通知,但我似乎无法使其与应用程序图标垂直居中.有任何想法吗?
就像一些人建议的那样,我曾经RemoteViews自定义我的通知,如下所示:
final RemoteViews views = new RemoteViews(getPackageName(), R.layout.notification_new_message);
views.setTextViewText(R.id.title, title);
Notification notification = new Notification();
notification.contentView = views;
notification.icon = R.drawable.push_icon;
notification.contentIntent = contentIntent;
manager.notify(Config.NTF_ID_GCM, notification);
Run Code Online (Sandbox Code Playgroud)
我在其中设置了notification_new_message.xml通知的理想外观。
| 归档时间: |
|
| 查看次数: |
1130 次 |
| 最近记录: |