显示自定义高度的自定义通知

时间:2015-07-16 07:16:50

标签: android

我正在尝试显示自定义高度的通知。我正在使用下面的代码生成通知,但它没有正确设置高度。

我应该如何更改此代码?
##########################################
波斯语中的同一个问题
##########################################
更多信息更多信息更多信息
更多信息更多信息
更多信息和更多信息

      public static void notficate1() {
              int icon = R.drawable.ic_launcher;
           long when = System.currentTimeMillis();
           Notification notification = new Notification(icon, "Custom Notification", when);

           NotificationManager mNotificationManager = (NotificationManager)getsrviso;

           RemoteViews contentView = new RemoteViews(pname, R.layout.custom_notification);
           contentView.setImageViewResource(R.id.image, R.drawable.ic_launcher);
           contentView.setTextViewText(R.id.title, "Custom notification");
           contentView.setTextViewText(R.id.text, "This is a custom layout");
           notification.contentView = contentView;

           Intent notificationIntent = new Intent(G.context, MainActivity.class);
           PendingIntent contentIntent = PendingIntent.getActivity(G.context, 0, notificationIntent, 0);
           notification.contentIntent = contentIntent;

          //notification.flags |= Notification.FLAG_NO_CLEAR; //Do not clear the notification
           notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
           notification.defaults |= Notification.DEFAULT_VIBRATE;  Vibration
            notification.defaults |= Notification.DEFAULT_SOUND; // Sound


           mNotificationManager.notify(1, notification);
    } 

1 个答案:

答案 0 :(得分:0)

根据文档,您有多种通知方式。您可能需要NotificationCompat.BigTextStyle()(文档here)。

根据this question,每种款式的最大高度为this conversation,且尺寸不能更改

相关问题