2015-08-03 51 views
0

我从#1绘制泡沫编程箭头

https://stackoverflow.com/a/20811323/1936925

实现以下类,但我需要这样的

enter image description here

泡沫我想了很多,但不要”不知道该怎么做。

为了得到上面的drawable,我需要做些什么编辑。

+0

你试图在画布上绘制这个红色的PNG图片,然后绘制文本 “35%”? –

+2

[Android ListView with Speech Bubble](http://blog.booleanbites.com/2012/12/android-listview-with-speech-bubble.html) – Kedarnath

+0

你可以很容易地使用9补丁。不需要任何自定义类。 – 2016-05-23 14:54:40

回答

0

试试这个:

public Bitmap overlay(Bitmap image, String content) { 
     BitmapFactory.Options options = new BitmapFactory.Options(); 
     options.inScaled = false; 
     options.inPreferredConfig = Bitmap.Config.ARGB_8888; 
     //My bg bitmap, use yours 
     Bitmap background = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(MapActivity.context.getResources(), R.drawable.marker_base, options), marker_width, marker_height, true); 
     //your red bitmap here 
     Bitmap bmOverlay = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig()); 
     Canvas canvas = new Canvas(bmOverlay); 
     Paint paint = new Paint(); 
     paint.setFilterBitmap(true); 
     canvas.drawBitmap(background, new Matrix(), paint); 
     canvas.drawBitmap(image, 3, 3, paint); 

     if (content != null) 
     { 
      //Use your TextSize and Color and paddings 
      paint = new Paint(); 
      paint.setColor(Color.BLACK); 
      if (content.length() < 11) 
       paint.setTextSize(13); 
      else 
       paint.setTextSize(10); 
      //30/28, 17 - my paddings 
      canvas.drawText(content, (content.length() < 11)?30:28, 17, paint); 
     } 
     return bmOverlay; 
    } 
0

解决

mPointer.rLineTo(80, 0); 
mPointer.rLineTo(0, 60); 
mPointer.rLineTo(-(80), -60); 
mPointer.close();