0

我想让通知图像适合通知的高度,如下所示:

在此处输入图像描述

但我看到的是这样的:

在此处输入图像描述

我的代码是:

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

我的意思是第二种情况下的光子(第二张照片)很小,文字在它下面,但我想像第一种情况一样,照片全高,文字留给照片

4

1 回答 1

0

请查看通知 UI 指南。您可能希望使用
setLargeIcon(aBitmap)
NotificationCompat.Builder(适用于 Android 3.0 之前的设备)或 Notification.Builder 中的方法,而不是 setSmallIcon。

于 2013-06-07T23:11:48.160 回答