2014-03-25 38 views
0

代碼片段:該方法是getBitmap在其上的drawText invisibile在機器人4.4

public void showImageView() { 
    imageView.setBitmap(getBitmap("something", getActivity())); 
} 


public static Bitmap getBitmap(String content, Context context) { 
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), 
      R.drawable.kfunsdk_stamp_bg) 
      .copy(Bitmap.Config.ARGB_4444, true); 
    int width = bitmap.getWidth(); 
    int height = bitmap.getHeight(); 
    int typeSize = (int) (height/1.7); 
    int left = (int) ((width - typeSize * content.length())/1.8); 
    Paint paint = new Paint(); 
    paint.setTextSize(typeSize); 
    paint.setColor(Color.WHITE); 
    paint.setTextAlign(Paint.Align.LEFT); 
    paint.setAntiAlias(true); 
    paint.setTypeface(Typeface.DEFAULT); 

    Canvas canvas = new Canvas(bitmap); 

    canvas.save(); 

    int top = (int) ((height - typeSize)/2.5) + typeSize; 

    canvas.drawText(content, left, top, paint); 

    canvas.restore(); 
    return bitmap; 
} 

這是在機器人4.4結果繪製位圖,其中的drawText()。在機器人4.3 reuslt

enter image description here

使用相同的代碼運行

enter image description here

+0

替換位圖構造嘗試用'paint.setStrokeWidth(4);' –

+0

I」已經嘗試過仍然不起作用 –

回答

0

嘗試用 Bitmap.Config.ARGB_8888