android - How to Custom Heads-up notification layout? -
in project, need change heads-up notification layout.
i have custom 2 remoteview, 1 notification.contentview, 1 notification.bigcontentview , succeed.
when want use notification.builder.addaction add click button, use system layout not mine.
i changed way, custom layout & click button in own layout, show 64dp height.
notification.builder nb = new notification.builder(notificationdemo.this); pendingintent pi = pendingintent.getactivity(notificationdemo.this, 1, new intent(notificationdemo.this, mainactivity.class), intent.flag_activity_new_task); nb.setfullscreenintent(pi, true); nb.setsmallicon(r.drawable.notification_icon); //nb.addaction(r.drawable.ic_delete, getresources().getstring(r.string.app_name), pi); remoteviews contentview = new remoteviews(getpackagename(), r.layout.notification_demo); remoteviews bigcontentview = new remoteviews(getpackagename(), r.layout.notification_demo_bigg); notification mno = nb.build(); mno.bigcontentview = bigcontentview; mno.contentview = contentview; nm.notify(10000, mno); second way:
notification.builder nb = new notification.builder(notificationdemo.this); pendingintent pi = pendingintent.getactivity(notificationdemo.this, 1, new intent(notificationdemo.this, mainactivity.class), intent.flag_activity_new_task); nb.setfullscreenintent(pi, true); nb.setsmallicon(r.drawable.notification_icon); nb.addaction(r.drawable.ic_delete, getresources().getstring(r.string.app_name), pi); remoteviews contentview = new remoteviews(getpackagename(), r.layout.notification_demo); remoteviews bigcontentview = new remoteviews(getpackagename(), r.layout.notification_demo_bigg); notification mno = nb.build(); mno.bigcontentview = bigcontentview; mno.contentview = contentview; nm.notify(10000, mno); third way, add actionbutton in layout.
in lollipop notification has new field named headsupcontentview. use custom remoteview, set headsupcontentview. can change.
Comments
Post a Comment