Здравствуйте. Я пытаюсь создать настраиваемое уведомление, но значок addAction, smallIcon и largeicon, отображается неправильно, затем я хочу создать настраиваемое уведомление без значка и поместить его в макет.
Возможно ли это?
Мой код:
public static NotificationCompat.Builder createNotification(Context context, String message){
String packageName = context.getPackageName();
RemoteViews notificationLayout = new RemoteViews(packageName, R.layout.notification);
RemoteViews notificationLayoutExpanded = new RemoteViews(packageName, R.layout.notification_expanded);
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo_solo)
.setStyle(new android.support.v4.app.NotificationCompat.DecoratedCustomViewStyle())
.setCustomBigContentView(notificationLayoutExpanded)
.setCustomContentView(notificationLayout);
return builder;
}
...
NotificationCompat.Builder builder = AssistanceNotification.createNotification(this, message);
Notification notification = builder.addAction(R.drawable.ic_gps, getString(R.string.assits), intentAssist)
.addAction(R.drawable.ic_gps, getString(R.string.omit), intentOmit)
.setTimeoutAfter(TIMEOUT) // works only for api > 26
.build();
AssistanceNotification.notify(this, notification);
...
Схема уведомления:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="64dp" >
<ImageView
app:srcCompat="@drawable/ic_logo_alert"
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Collpasepd notification"
style="@style/TextAppearance.Compat.Notification.Title"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Hello from colapse notification"
style="@style/TextAppearance.Compat.Notification.Info"/>