私の通知に「bigContentView」を使用してカスタムコンテンツを配置しています。ホーム画面のウィジェット用に既に設定したものと同じremoteViews
に設定しています。私が抱えている問題は、通知コンテンツの高さが一定のままで、コンテンツに合わせて縮小しないということです。私は、ウィジェットのサイズを変更する場合の例としてAndroid:通知内のbigContentView周りのスペース
は、新しいウィジェットのコンテンツは、通知に配置され、それは常に(白に充填されたギャップを有する)同じ高さである。
関連するコードは次のとおりです。
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(placeName)
.setContentText(contentText)
.setSmallIcon(drawableId)
.setOngoing(false)
.setPriority(Notification.PRIORITY_MIN)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.build();
notification.bigContentView = remoteViews;
notificationManager.notify(0, appWidgetId, notification);
をそしてremoteViewsは、以下のレイアウトに基づいています。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_margin"
android:id="@+id/widget" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView_port"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" />
</RelativeLayout>
(レイアウトには他にもいくつかのコンテンツがありますが、上記のレイアウトは基本的なものですが、残りは重要な効果はないと確信しています...)
EDIT:ImageViewのがで更新されます。
remoteViews.setImageViewUri(imageViewId, uri);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
私は実際にremoteViews
コンテンツをフィッティング通知を防ぐために、明らかに間違って何をやっていますか?
そして、どこで、どのようにあなたが 'ImageVIew'の画像を設定するか、あなたは示すことができましたか? – rom4ek
@ rom4ekこの情報で質問を更新しました – drmrbrewer
'wrap_content'の高さで' RelativeLayout'と 'ImageView'を試しましたか? – sohailehmad