ste*_*wpf 21 notifications android
我需要创建一个包含更长文本的通知,这可能吗?默认情况下不是,但您可以使用自定义布局,这就是我所做的.现在我可以显示多行,但正如您所看到的,文本仍然被破坏/未完全显示?):有人可以告诉我我做错了什么/如果通知的大小有固定的限制吗?如果你看一下屏幕截图,你会注意到,还剩下很多空间......感谢任何提示!
BTW这里是用于自定义布局的XML,基于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>
Run Code Online (Sandbox Code Playgroud)

Cis*_*elo 48
对于Jelly Bean及更高版本,您可以使用可扩展通知.最简单的方法是使用NotificationCompat.BigTextStyle进行通知.
像这样:
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
bigTextStyle.setBigContentTitle(getString(R.string.title));
bigTextStyle.bigText(getString(R.string.long_explanation));
mBuilder.setStyle(bigTextStyle);
Run Code Online (Sandbox Code Playgroud)
小智 41
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());
Run Code Online (Sandbox Code Playgroud)
曾经有人试过https://developer.android.com/guide/topics/ui/notifiers/notifications.html
通知视图受到65sp高度的限制.这是实现细节,没有记录,并且已在Android 4.1中进行了更改以支持可扩展通知.所以不要依赖这个特定的值,而是依赖于视图的高度有限的事实.
这是status_bar_latest_event.xml用于在通知区域中膨胀视图:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="65sp"
android:orientation="vertical"
>
<com.android.server.status.LatestItemView android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="64sp"
android:background="@drawable/status_bar_item_background"
android:focusable="true"
android:clickable="true"
android:paddingRight="6sp"
>
</com.android.server.status.LatestItemView>
<View
android:layout_width="match_parent"
android:layout_height="1sp"
android:background="@drawable/divider_horizontal_bright"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
50179 次 |
| 最近记录: |