wve*_*ese 2 notifications android expandable remoteview android-4.2-jelly-bean
我在豆形软糖做了一个自定义的远程视窗,如所描述这里,并将其设置为一个通知的bigContentView。
notification.bigContentView = customNotifView;
Run Code Online (Sandbox Code Playgroud)
我试图在扩展后将自定义布局放置在标准 contentView下方;像这样的东西。
问题是自定义布局在展开后覆盖了标准的contentView。
有没有办法做到这一点?
我通过为名为 的 contentView 创建自定义布局来解决layout_base_content_notification.xml,这与 Android 为通知提供的(手工)布局完全相同。
RemoteViews collapsedViews = new RemoteViews(c.getPackageName(), R.layout.layout_base_content_notification);
Notification noti = builder.build();
noti.contentView = collapsedViews;
Run Code Online (Sandbox Code Playgroud)
然后我将它包含在一个 customLayout 中,称为layout_big_content_notification.xml:
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/layout_base_content_notification" />
Run Code Online (Sandbox Code Playgroud)
并将其添加为 bigContentView:
RemoteViews expandedViews = new RemoteViews(c.getPackageName(), R.layout.layout_big_content_notification);
noti.bigContentView = expandedViews;
Run Code Online (Sandbox Code Playgroud)
现在,在扩展之后,bigContentView 替换了 contentView,但它们的标题是相同的。
请让我知道是否有更好的解决方案。
| 归档时间: |
|
| 查看次数: |
5197 次 |
| 最近记录: |