2

I am trying to display a big/expanded Custom Notification on Android API 23 but the action buttons don't show.

Bellow you can find my code. I also tried adding actions, but I was not successful.

I also tried other answers from other questions but they didn't work.

Here is my code:

Notification.Builder mBuilder =
                new Notification.Builder(this)
                        .setSmallIcon(R.drawable.mailunread)
                        .setContentTitle("My notification")
                        .setContentText("Hello World!").setWhen(0);
Notification notification  =  mBuilder.build();
RemoteViews contentView=new RemoteViews(this.getPackageName(), R.layout.cell_notification);
notification.bigContentView = contentView;
 NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, notification);

And here is my view:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="match_parent"
 android:layout_height="match_parent">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="New offer for search" android:textColor="@android:color/black" />
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" android:text="vendor" android:textColor="@android:color/black" />

<ImageView
    android:layout_width="100dp" android:layout_gravity="center"
    android:layout_height="wrap_content" android:src="@drawable/iphone1"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content" android:text="elevator pitch" android:textColor="@android:color/black" />

<Button
    android:id="@+id/buttonNotification"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Respond Now"
    android:textColor="@android:color/black"
    android:layout_weight="20"/>



 </LinearLayout>
Daniel Benedykt
  • 6,496
  • 12
  • 51
  • 73

1 Answers1

0

Notification height in Android is limited to 256dp. If your RemoteViews layout exceeds that, then Views will be clipped at the bottom. If you put your Button at the top of your layout, you will see that it shows up.

IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147