如何删除' now'以及我的应用中通知布局的下拉箭头。我使用单一布局进行通知,但它正在扩展。我将高度保持在64dp和50dp,但尺寸没有变化
// Get the layouts to use in the custom notification
RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.notification_small);
//RemoteViews notificationLayoutExpanded = new RemoteViews(getPackageName(), R.layout.notification_large);
notificationLayout.setTextViewText(R.id.otpText,otp);
// Apply the layouts to the notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext());
builder.setSmallIcon(R.drawable.ic_launcher_foreground)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(notificationLayout)
.setPriority(PRIORITY_MAX)
.setDefaults(DEFAULT_SOUND)
.setColor(getResources().getColor(R.color.colorAccent))
.setDefaults(DEFAULT_VIBRATE)
.setContentIntent(pendingIntent);
答案 0 :(得分:0)
只需使用
builder.setSmallIcon(R.drawable.ic_launcher_foreground)
...
.setWhen(0)
...
答案 1 :(得分:0)
根据你可以使用的Documentation:
setWhen(long when)
setShowWhen(boolean show);
默认情况下setShowWhen
为真,因此您可以将其设置为setShowWhen(false)
以删除时间戳。