Android,Xamarin:针对自定义android通知自定义布局大小

时间:2018-10-23 09:44:33

标签: android

使用此代码,我设法从XML文件中获得了一个要膨胀和显示自定义布局的通知。但是,实际通知的大小始终相同。如果我将布局设置为更大的高度,则通知不会显示其中一半。

如何自定义通知的大小?

void DispatchNotificationThatServiceIsRunning()
        {
            _notificationIsLive = true;

            RemoteViews contentView = new RemoteViews(PackageName, Resource.Layout.lel);

                Task.Delay(_countDownFirstRound).ContinueWith(t =>
                {
                    notificationBuilder
                    .SetSmallIcon(Resource.Drawable.btn_icon_header)
                    .SetCustomContentView(contentView);

                    var notificationManager = (NotificationManager)GetSystemService(NotificationService);
                    notificationManager.Notify(50, notificationBuilder.Build());

                    DispatchNotificationThatServiceIsRunning();//This is for repeate every 1s.

                    _countDownFirstRound = 50;

                    // Click on notification, and return to app. Only works, because _2TimerRunning is set as : "LaunchMode = LaunchMode.SingleInstance"
                    Intent notificationIntent = new Intent(this, typeof(Activity_Player));
                    notificationIntent.SetAction(Intent.ActionMain);
                    notificationIntent.AddCategory(Intent.CategoryLauncher);
                    PendingIntent contentIntent = PendingIntent.GetActivity(this, 1, notificationIntent, PendingIntentFlags.UpdateCurrent);
                    notificationBuilder.SetContentIntent(contentIntent);

                }, 

                TaskScheduler.FromCurrentSynchronizationContext());

0 个答案:

没有答案