简体   繁体   English

android通知图像不符合预期

[英]android notification image not as expected

i want to have notification image fit the height of the notification like this: 我想让通知图像适合通知的高度,如下所示:

在此处输入图片说明

but what i see is like this: 但是我看到的是这样的:

在此处输入图片说明

my code is: 我的代码是:

Client client = new Client(Configuration.getServer());
String str = client.getBaseURI("offers");
try {
    JSONArray json = new JSONArray(str);
    for (int i = 0; i < json.length(); i++) {
        JSONObject oneOffer = json.getJSONObject(i);
        int offerID = oneOffer.getInt("ID");
        String offerDescriptoin = oneOffer.getString("Description");
        String endDate = oneOffer.getString("EndDate");
        String startDate = oneOffer.getString("StartDate");
        JSONObject restaurant = oneOffer.getJSONObject("Restaurant");
        int restaruantID = restaurant.getInt("ID");
        String restaurantName = restaurant.getString("Name");
        Offer offer = new Offer(offerID, startDate, endDate,
                offerDescriptoin, new Restaurant(restaruantID,
                        restaurantName));
        Log.d("DES", offerDescriptoin);
        Offer.getAllOffers().put(offer.getID(), offer);
        Intent intent = new Intent(this, OfferNotification.class);
        PendingIntent pIntent = PendingIntent.getActivity(this, 0,
                intent, 0);
        Uri soundUri = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.ic_launcher)

                .setContentTitle("Offer from " + restaurantName)
                .setContentText(offerDescriptoin).setSound(soundUri);
        // Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(this, OfferNotification.class);
        resultIntent.putExtra("offerID", offer.getID());
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

        stackBuilder.addParentStack(OfferNotification.class);

        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        mNotificationManager.notify(offer.getID(), mBuilder.build());
    }
} catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

i mean the photon in the second case (second photo )is small and the text becomes under it, but i want like the first case when the photo is in all the height and the text left to the photo 我的意思是第二种情况下的光子(第二张照片)很小,并且文字在其下,但是我想要像第一种情况那样,当照片处于所有高度时,文字留在照片上

Please check Notifications UI guide . 请检查“ 通知用户界面指南” You may want to use 您可能要使用
setLargeIcon(aBitmap)
method from NotificationCompat.Builder (for devices prior Android 3.0) or Notification.Builder instead of setSmallIcon. (适用于Android 3.0之前的设备)或Notification.Builder(而不是setSmallIcon)中的NotificationCompat.Builder方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM