android通知图像不符合预期

时间:2013-06-07 23:00:01

标签: android notifications android-notifications

我希望通知图像符合通知的高度,如下所示:

enter image description here

但我看到的是这样的:

enter image description here

我的代码是:

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();
}

我的意思是第二种情况下的光子(第二张照片)很小,文字在它下面,但我想要的第一种情况是照片处于所有高度而文字留在照片

1 个答案:

答案 0 :(得分:0)

请检查Notifications UI guide。您可能想要使用
setLargeIcon(aBitmap)来自NotificationCompat.Builder(适用于Android 3.0之前的设备)或Notification.Builder而非setSmallIcon的方法。