2
我有這樣的方法,其中我畫一些文字上的圖像:Bitmap.decodeResource調整圖像
public BitmapDrawable writeOnDrawable(int drawableId, String text){
Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId);
Typeface mFace = Typeface.createFromAsset(this.getAssets(),"fonts/progbot.ttf");
Paint paint = new Paint();
paint.setStyle(Style.FILL);
paint.setColor(Color.RED);
paint.setTypeface(mFace);
paint.setTextSize(30);
Canvas canvas = new Canvas(bm);
canvas.drawText(text, 0, bm.getHeight()/2, paint);
return new BitmapDrawable(bm);
}
這是我如何調用此方法:
lineIconView.setImageDrawable(writeOnDrawable(R.drawable.icon_line_numbre, linea.getNumero()));
這ImageView的(lineIconView
)已擁有R.drawable.icon_line_numbre
資源集。如果我沒有撥打writeOnDrawable
功能,則圖像會以其原始尺寸顯示,但在調用圖像後,圖像會大大減小。
這是正常的行爲嗎?