我是关于Android的新手,我已经创建了一个显示电池百分比的小部件,但在我的手机上(Galaxy nexus)显示正常,但在其他密度不同的情况下显示非常大。我已经在每个地方进行了搜索,但我没有找到任何解决方案,使得构建位图在每个移动设备中都显示出来......有人可以帮助我吗?
public Bitmap buildBitmap(String texto, Context context) {
Bitmap myBitmap = Bitmap.createBitmap(94, 94, Bitmap.Config.ARGB_4444);
Typeface font = Typeface.createFromAsset(context.getAssets(),
"batmfont.ttf");
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(font);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(35);
paint.setShadowLayer(1, 1, 1, Color.rgb(51, 51, 51));
paint.setTextAlign(Align.CENTER);
Canvas myCanvas = new Canvas(myBitmap);
myCanvas.drawText(texto, 47, 54, paint);
return myBitmap;
}