android中自定义通知,在android中的大自定义通知

我试图使我的自定义通知类似于这一个

XGn8y.png 我发现了一堆类似的问题在这里和互联网上的例子,但没有人帮助我。在android中的大自定义通知

这里是我的代码:

RemoteViews bigView = new RemoteViews(mContext.getApplicationContext().getPackageName(), R.layout.notification_playback);

Intent i = new Intent(MainActivity.ACTION_PLAYER, null, mContext, MainActivity.class);

i.putExtra("CURRENT_TRACK", t);

i.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent pi = PendingIntent.getActivity(mContext, 0, i, 0);

Notification n = new NotificationCompat.Builder(mContext)

.setContentTitle(t.getName())

.setContentText(t.getArtistName())

.setContentIntent(pi)

.setSmallIcon(R.drawable.ic_notification)

.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_launcher))

.setOngoing(true)

.setContent(bigView)

.setWhen(System.currentTimeMillis())

.build();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)

n.bigContentView = bigView;

NotificationManager notifyMgr = (NotificationManager)mContext.getSystemService(Context.NOTIFICATION_SERVICE);

notifyMgr.notify(0, n);

它出现在默认的大小,成为大小我只后,就可以长按预期。

是否可以在不长时间使其立即变大尺寸?如果有,我该怎么办? 谢谢!

+0

这是[另一个问题](http://stackoverflow.com/questions/21237495/create-custom-big-notifications),可能会帮助你。 –

2014-10-29 13:20:21

+0

@TheRealBenjamin谢谢,但我已经试过了。它说'技巧不是使用setStyle(),而是在构建它之后手动设置Notification的bigContentView字段,但正如你所看到的,我正在做这件事。 –

2014-10-29 13:25:18

+1

http://stackoverflow.com/questions/18367631/change-notification-layout –

2014-10-29 13:29:53

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值