通知大小

时间:2014-07-31 12:29:33

标签: java android notifications

有可能设置通知的大小(我不希望通过点击和向下滑动的解决方案来查看更大的图片)。 我创建了一个带有自定义布局的代码,当我在手机上打开我的应用程序时,当我放大时会看到通知,我看到了这个通知的壁纸,但我想要这样: enter image description here

没有放大通知,我想要一个带壁纸的静态大通知,这可能吗?

我的代码:

        Intent resultIntent = new Intent(this, MyActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(MyActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
                0, PendingIntent.FLAG_UPDATE_CURRENT);
        RemoteViews expandedView = new RemoteViews(this.getPackageName(),
                R.layout.awesome_big_beast_notification);
        expandedView.setTextViewText(R.id.text1, "TEST NOTIFY");
        BitmapFactory.Options options = new BitmapFactory.Options();
        //we have a cute kitten for a background and also we can display image in right corner
        Bitmap result = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
                getResources(), R.drawable.ic_launcher),
                30, 30, true);
        expandedView.setImageViewBitmap(R.id.image1, result); //in here we can set the size :)
        Notification notification = new Notification.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(
                        getResources(), R.drawable.meow))
                .setAutoCancel(true)
                .setContentIntent(resultPendingIntent)
                .setContentTitle("Don't touch me")
                .setStyle(new Notification.BigPictureStyle()
                        .bigPicture(Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
                                        getResources(), R.drawable.ic_launcher),
                                200, 200, true)))
                .build();
        notification.bigContentView = expandedView;

        ((NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE))
                .notify(0, notification);

0 个答案:

没有答案