本帖最后由 linbill168 于 2012-01-23 13:52:13 编辑

解决方案 »

  1.   

    我自己试过一个方法,用layerDrawable
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
        <item id="@+id/layerBit2"> 
          <bitmap android:src="@drawable/notify"  android:gravity="center" /> 
        </item>  
    </layer-list>Notification notify = new Notification();
    //为Notification设置图标,该图标显示在状态栏 ,图标是必须要设置的
    LayerDrawable layerDrawable = (LayerDrawable) getResources().getDrawable(R.drawable.layerbit);
    //通过层次图形上的id设置某一项的图形
    layerDrawable.setDrawableByLayerId(R.id.layerBit2, getResources().getDrawable(R.drawable.icon));
    notify.icon = R.drawable.layerbit;但我修改不了layerDrawable中的item
      

  2.   

    他是把drawable转换成bitmap,再把检测到的数字画上去的。
      

  3.   

    2楼的兄弟,能否具体给出个例子,现在我的关键问题是不知道怎么把生成好的带数字的bitmap显示到状态栏上去。
      

  4.   

    Notification.icon只能引用ID来显示,一直找不到方法
      

  5.   

    我记得傲慢的上校博客上有篇文章是写在联系人的图标上写上一个数字,代表有多少个联系人的例子。另外我觉得也可以写一个xml,然后通过相对布局,把一个textview盖在imageview的右下角,我有个小程序就是这么干的,不过有时候相对布局在ide上的视图显示有bug,只有运行了才知道位置对不对
      

  6.   

    我记得Notification有个设置xml作为视图的方法。不一定非得icon
      

  7.   

    代码大致如下
    private void showNotification() {
    Notification notification = new Notification(R.drawable.ic_launcher,
    "驱蚊神手正在运行", System.currentTimeMillis() + 2000);
    notification.flags = Notification.FLAG_NO_CLEAR
    | Notification.FLAG_ONGOING_EVENT; notification.contentView = makeRemoteView(); Intent notificationIntent = new Intent(this, StartActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
    notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    notification.icon = R.drawable.wenziicon;
    notification.contentIntent = contentIntent;
    manager.notify(1, notification);
    } private RemoteViews makeRemoteView() {
    RemoteViews mRemoteViews = new RemoteViews(getPackageName(),
    R.layout.notification);
    return mRemoteViews;
    }
      

  8.   

    你说的那个帖子是显示联系人的那个吧,他用的就是RemoteViews,这个我试试了不行才来问的,他显示的图片是在状态栏下拉的面板中,不是在状态栏上的,也就是RemoteViews这个是代替状态栏面板中显示信息用的。不过我也不知道是不是全是这样,但我用过的结果是这样的,我搞安卓开发是第一次