使用菱形形状扩展ImageView

时间:2015-12-17 13:55:57

标签: android imageview

您好有谁知道如何制作具有此形状的ImageView对象?                                                  http://smorenburg.me/shape.png

   @Override
   protected void onDraw(Canvas canvas) {
          Drawable drawable = getDrawable();
          if (drawable == null) {
                 return;
          }
          if (getWidth() == 0 || getHeight() == 0) {
                 return;
          }
          Bitmap b = ((BitmapDrawable) drawable).getBitmap();
          Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);
          int w = getWidth(), h = getHeight();
          Bitmap roundBitmap = getRoundedCroppedBitmap(bitmap, w);
          canvas.drawBitmap(roundBitmap, 0, 0, null);
   }

0 个答案:

没有答案