问题描述
我需要用更长的文本创建通知,这可能吗?默认情况下不是,但您可以使用
I need to create a Notification with a longer text, is that possible? By default it is not, but you can use a custom layout, which is what I did. Now I can display multiple lines, but as you can see, the text is still broken / not displayed completely? ): Can someone please tell me what I am doing wrong / if there's a fixed limit for the size of notifications? If you look at the screenshot you will notice, that there is still a lot of space left... Thanks for any hint!
BTW here's the XML used for the custom layout, based on http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomNotification
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dp"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000"
/>
</LinearLayout>
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.setContentText(message)
.setDefaults(NotificationCompat.DEFAULT_SOUND)
.setContentIntent(contentIntent)
.setAutoCancel(true);
mNotificationManager.notify(requestID, mBuilder.build());
once reffer https://developer.android.com/guide/topics/ui/notifiers/notifications.html
这篇关于Android 多行通知/带有较长文本的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!