我正在尝试将Canvas放入Drawable ...下面的代码......任何帮助都表示赞赏!!
Drawable marker = makeMarker();
boundCenterBottom(marker);
item.setMarker(marker);
private Drawable makeMarker(){
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.BLACK);
paint.setTextSize(20);
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
c.drawText("Some Text", 100, 100, paint);
Drawable d = new BitmapDrawable(b);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
return d;
}
答案 0 :(得分:0)
getIntrinsicWidth()不适用于事件onCreate()并且等于零。所以,没有什么幸福的