【问题标题】:multiline notification in android different behaviour in different deviceandroid中的多行通知在不同设备中的不同行为
【发布时间】:2014-12-12 07:44:08
【问题描述】:

我正在尝试在多行中显示通知文本。

我正在使用此代码来执行此操作。

    NotificationManager mNotificationManager;
    String msg = "Do you want to share Fantasy Cricket on Twitter/FB/Google+?";

    mNotificationManager = (NotificationManager) this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
            this).setSmallIcon(R.drawable.app_icon)

    .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .setContentText(msg).setAutoCancel(true);

    mBuilder.setContentTitle("Change team");
    mNotificationManager.notify(notId, 123, mBuilder.build());

它在两个设备上的显示方式不同。

第一台设备

第二台设备

在第一个设备中,它仅在多行中显示精细文本,但在第二个设备中,它仅在一行中显示,仅删除尾随空格。

为什么两者的行为不同。我在这里错过了什么吗?如果这有什么不同的话,这两款设备都有 kitkat。

更新

根据@leo 的回答,当只有一个通知时,它将显示在两行中。但我检查了 TOI 应用程序,它总是分两行显示。

TOI 的截图

【问题讨论】:

    标签: android android-layout notifications customization android-notifications


    【解决方案1】:

    Docs 说默认情况下只展开顶部通知。所以也许你正在比较的另一个应用程序完全使用custom notification layout(特别是因为我在那里看不到标题)?

    【讨论】:

    • 您可以在我的代码中看到我正在使用 BigTextStyle。仍然没有按预期工作。
    • 是的,很抱歉。更新了我的答案。
    【解决方案2】:

    如果有人像我一样陷入其中,那么根据LINK Users can drag down on a notification in the drawer to reveal the expanded view, which shows additional content and action buttons, if provided. 这在三星设备上经常发生...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-02
      • 2021-01-24
      • 2017-06-26
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      相关资源
      最近更新 更多