/*
   * (non-Javadoc)
   *
   * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
   */
  @SuppressLint("NewApi")
  @SuppressWarnings("deprecation")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
      /*
       * TODO: build the layout programmatically
       */
      view = mLayoutInflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_field, null);
    }

    // set the background to a colored circle
    // TODO: allow to customize the shape
    Shape shape = new ArcShape(0, 360);
    ShapeDrawable bg = new ShapeDrawable(shape);
    bg.getPaint().setColor(mPalette.getColor(position));

    if (android.os.Build.VERSION.SDK_INT < 16) {
      view.setBackgroundDrawable(bg);
    } else {
      view.setBackground(bg);
    }

    return view;
  }
Example #2
0
 private Drawable createSelector(int color) {
   ShapeDrawable darkerCircle = new ShapeDrawable(new OvalShape());
   darkerCircle.getPaint().setColor(translucentColor(shiftColorUp(color)));
   StateListDrawable stateListDrawable = new StateListDrawable();
   stateListDrawable.addState(new int[] {android.R.attr.state_pressed}, darkerCircle);
   return stateListDrawable;
 }
Example #3
0
 private void drawKeyboardBackground(Canvas canvas, String colour) {
   ShapeDrawable background = new ShapeDrawable(new RectShape());
   background.getPaint().setColor(Color.parseColor(colour));
   background.setBounds(
       (int) getX(), (int) getY(), (int) getX() + getWidth(), (int) getY() + getHeight());
   background.draw(canvas);
 }
  public DrawableLayeredButton(Context context, int topLayer, boolean hasBorder) {
    Drawable topLayerDrawable = context.getResources().getDrawable(topLayer);
    Drawable greenButtonDrawable = context.getResources().getDrawable(mGreenButtonResource);

    InsetDrawable topLayerInset = new InsetDrawable(topLayerDrawable, Utilities.convertToPx(8));
    InsetDrawable greenButtonInset =
        new InsetDrawable(greenButtonDrawable, Utilities.convertToPx(5));

    int width = Utilities.convertToPx(40);
    int height = Utilities.convertToPx(40);

    ShapeDrawable border = new ShapeDrawable(new OvalShape());
    border.getPaint().setColor(0xffabab25);
    border.setBounds(0, 0, width, height);

    Drawable[] nonActivatedlayers = new Drawable[2];
    nonActivatedlayers[0] = greenButtonInset;
    nonActivatedlayers[1] = topLayerInset;

    LayerDrawable nonActivatedLayer = new LayerDrawable(nonActivatedlayers);

    Drawable[] activatedlayers = new Drawable[3];
    activatedlayers[0] = border;
    activatedlayers[1] = greenButtonInset;
    activatedlayers[2] = topLayerInset;

    LayerDrawable activatedLayer = new LayerDrawable(activatedlayers);

    mDrawable = new StateListDrawable();
    if (hasBorder) {
      mDrawable.addState(new int[] {android.R.attr.state_checked}, activatedLayer);
    }

    mDrawable.addState(new int[] {}, nonActivatedLayer);
  }
Example #5
0
  /**
   * Generates bitmap used for drawing button.
   *
   * @param radius Radius of button in pixels.
   */
  @Override
  void generateBitmap() {
    super.generateBitmap();
    // Size and shape
    buttonShape.setShape(new OvalShape());
    buttonShape.setBounds(
        new Rect(PADDING, PADDING, (int) radius * 2 - PADDING, (int) radius * 2 - PADDING));

    // Create button bitmap and render shape
    buttonBitmap = Bitmap.createBitmap((int) radius * 2, (int) radius * 2, Bitmap.Config.ARGB_4444);
    Canvas handleCanvas = new Canvas(buttonBitmap);
    buttonShape.getPaint().set(parent.fillPaint);
    buttonShape.draw(handleCanvas);

    // Set text style
    textPaint.setStyle(Paint.Style.FILL);
    textPaint.setTypeface(Typeface.DEFAULT_BOLD);
    textPaint.setTextAlign(Paint.Align.CENTER);
    textPaint.setColor(Color.BLACK);
    // Set size (one character has a standard design, more has dynamic size)
    if (label.length() == 1) textPaint.setTextSize(radius);
    else textPaint.setTextSize(radius / label.length() * 2.5f);

    // Set paint to clear text from button
    textPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));

    // Render the button
    handleCanvas.drawText(label, radius, radius + (textPaint.getTextSize() * .33333f), textPaint);
  }
Example #6
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   for (ShapeDrawable shape : shapes) {
     shape.draw(canvas);
   }
 }
  public CircleImageViewSupport(Context context, int color, final float radius) {
    super(context);
    final float density = getContext().getResources().getDisplayMetrics().density;
    final int diameter = (int) (radius * density * 2);
    final int shadowYOffset = (int) (density * Y_OFFSET);
    final int shadowXOffset = (int) (density * X_OFFSET);

    mShadowRadius = (int) (density * SHADOW_RADIUS);

    ShapeDrawable circle;
    if (elevationSupported()) {
      circle = new ShapeDrawable(new OvalShape());
      ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
    } else {
      OvalShape oval = new OvalShadow(mShadowRadius, diameter);
      circle = new ShapeDrawable(oval);
      ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, circle.getPaint());
      circle
          .getPaint()
          .setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR);
      final int padding = mShadowRadius;
      // set padding so the inner image sits correctly within the shadow.
      setPadding(padding, padding, padding, padding);
    }
    circle.getPaint().setColor(color);
    setBackgroundDrawable(circle);
  }
Example #8
0
 // Throw IllegalArgumentException if shape has illegal value.
 private void setShape() {
   ShapeDrawable drawable = new ShapeDrawable();
   // Set color of drawable.
   drawable
       .getPaint()
       .setColor(
           (backgroundColor == Component.COLOR_DEFAULT)
               ? SHAPED_DEFAULT_BACKGROUND_COLOR
               : backgroundColor);
   // Set shape of drawable.
   switch (shape) {
     case Component.BUTTON_SHAPE_ROUNDED:
       drawable.setShape(new RoundRectShape(ROUNDED_CORNERS_ARRAY, null, null));
       break;
     case Component.BUTTON_SHAPE_RECT:
       drawable.setShape(new RectShape());
       break;
     case Component.BUTTON_SHAPE_OVAL:
       drawable.setShape(new OvalShape());
       break;
     default:
       throw new IllegalArgumentException();
   }
   // Set drawable to the background of the button.
   view.setBackgroundDrawable(drawable);
   view.invalidate();
 }
Example #9
0
  private LayerDrawable createDrawable(int radius, int topColor, int bottomColor) {

    float[] outerRadius =
        new float[] {radius, radius, radius, radius, radius, radius, radius, radius};

    // Top
    RoundRectShape topRoundRect = new RoundRectShape(outerRadius, null, null);
    ShapeDrawable topShapeDrawable = new ShapeDrawable(topRoundRect);
    topShapeDrawable.getPaint().setColor(topColor);
    // Bottom
    RoundRectShape roundRectShape = new RoundRectShape(outerRadius, null, null);
    ShapeDrawable bottomShapeDrawable = new ShapeDrawable(roundRectShape);
    bottomShapeDrawable.getPaint().setColor(bottomColor);
    // Create array
    Drawable[] drawArray = {bottomShapeDrawable, topShapeDrawable};
    LayerDrawable layerDrawable = new LayerDrawable(drawArray);

    // Set shadow height
    if (isShadowEnabled && topColor != Color.TRANSPARENT) {
      // unpressed drawable
      layerDrawable.setLayerInset(0, 0, 0, 0, 0); /*index, left, top, right, bottom*/
    } else {
      // pressed drawable
      layerDrawable.setLayerInset(0, 0, mShadowHeight, 0, 0); /*index, left, top, right, bottom*/
    }
    layerDrawable.setLayerInset(1, 0, 0, 0, mShadowHeight); /*index, left, top, right, bottom*/

    return layerDrawable;
  }
  @Override
  protected void onDraw(Canvas canvas) {

    canvas.save();
    // 去除状态栏高度偏差
    canvas.translate(0, -mStatusBarHeight);

    if (!isDisappear) {
      if (!isOutOfRange) {
        // 画两圆连接处
        ShapeDrawable drawGooView = drawGooView();
        drawGooView.setBounds(rect);
        drawGooView.draw(canvas);

        // 画固定圆
        canvas.drawCircle(mStickCenter.x, mStickCenter.y, stickCircleTempRadius, mPaintRed);
      }
      // 画拖拽圆
      canvas.drawCircle(mDragCenter.x, mDragCenter.y, dragCircleRadius, mPaintRed);
      // 画数字
      canvas.drawText(text, mDragCenter.x, mDragCenter.y + dragCircleRadius / 2f, mTextPaint);
    }

    canvas.restore();
  }
Example #11
0
 private void validateSavedColorCode(String code, String key) {
   try {
     ShapeDrawable shapeDrawable = new ShapeDrawable();
     shapeDrawable.getPaint().setColor(Color.parseColor(code));
   } catch (Exception e) {
     mPreferences.edit().putString(key, null).commit();
   }
 }
 public VistaAMedida(Context contexto) {
   super(contexto);
   int x = 10, y = 10;
   int ancho = 300, alto = 50;
   miDrawable = new ShapeDrawable(new OvalShape());
   miDrawable.getPaint().setColor(0xff0000ff);
   miDrawable.setBounds(x, y, x + ancho, y + alto);
 }
  @Override
  protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);

    mFadingEdgeLeft.draw(canvas);
    mFadingEdgeRight.draw(canvas);
    if (mShowTopShadow) mShadow.draw(canvas);
    if (mShowBottomBar) mBottomBar.draw(canvas);
    if (mShowTab) mTabDrawable.draw(canvas);
  }
Example #14
0
 private void showLoading() {
   if (loadingDrawable == null) {
     loadingDrawable = new LoadingDrawable(loadingIv);
   }
   loadingIv.setImageDrawable(loadingDrawable);
   ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());
   shapeDrawable.getPaint().setColor(Color.parseColor("#ffffff"));
   loadingIv.setBackgroundDrawable(shapeDrawable);
   loadingDrawable.start();
 }
 private LayerDrawable makeClusterBackground() {
   mColoredCircleBackground = new ShapeDrawable(new OvalShape());
   ShapeDrawable outline = new ShapeDrawable(new OvalShape());
   outline.getPaint().setColor(0x80ffffff); // Transparent white.
   LayerDrawable background =
       new LayerDrawable(new Drawable[] {outline, mColoredCircleBackground});
   int strokeWidth = (int) (mDensity * 3);
   background.setLayerInset(1, strokeWidth, strokeWidth, strokeWidth, strokeWidth);
   return background;
 }
Example #16
0
 private boolean isDeletingExistingShape(int x, int y) {
   for (ShapeDrawable shape : shapes) {
     Rect bounds = shape.getBounds();
     if (bounds.contains(x, y)) {
       shapes.remove(shape);
       return (true);
     }
   }
   return (false);
 }
  public static StateListDrawable createBlueButtonDrawable(Context context) {

    float corner =
        TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP, 2, context.getResources().getDisplayMetrics());

    float[] corners = new float[] {corner, corner, corner, corner, corner, corner, corner, corner};

    ShapeDrawable shapeDrawable = new ShapeDrawable();
    shapeDrawable.getPaint().setColor(TgR.color.blue_color);
    Shape rrs = new RoundRectShape(corners, null, null);
    shapeDrawable.setShape(rrs);

    ShapeDrawable shapeDrawablePressed = new ShapeDrawable();
    //        shapeDrawablePressed.getPaint().setColor((TgR.color.blue_color & 0x00FFFFFF) | (0xCC
    // << 24));
    shapeDrawablePressed.getPaint().setColor(TgR.color.main_theme_color);
    Shape rrsPressed = new RoundRectShape(corners, null, null);
    shapeDrawablePressed.setShape(rrsPressed);

    ShapeDrawable shapeDrawableDisable = new ShapeDrawable();
    shapeDrawableDisable.getPaint().setColor(0xFFD1D1D1);
    Shape rrsDisable = new RoundRectShape(corners, null, null);
    shapeDrawableDisable.setShape(rrsDisable);

    StateListDrawable sld = new StateListDrawable();
    sld.addState(new int[] {-android.R.attr.state_enabled}, shapeDrawableDisable);
    sld.addState(new int[] {android.R.attr.state_pressed}, shapeDrawablePressed);
    sld.addState(new int[] {android.R.attr.state_enabled}, shapeDrawable);

    return sld;
  }
Example #18
0
 public void setVolume(int volume) {
   mVolume = Math.max(0, Math.min(mVolumeMax, volume));
   final Rect r = mBar.getBounds();
   if (mVertical) {
     mCover.setBounds(
         r.left + mVolume * (r.right - r.left) / mVolumeMax, r.top, r.right, r.bottom);
   } else {
     mCover.setBounds(r.left, r.top, r.right, r.top + mVolume * (r.bottom - r.top) / mVolumeMax);
   }
   this.invalidate();
 }
Example #19
0
  @SuppressWarnings("deprecation")
  public void setBackground(int dipRadius, int badgeColor) {
    int radius = dip2Px(dipRadius);
    float[] radiusArray =
        new float[] {radius, radius, radius, radius, radius, radius, radius, radius};

    RoundRectShape roundRect = new RoundRectShape(radiusArray, null, null);
    ShapeDrawable bgDrawable = new ShapeDrawable(roundRect);
    bgDrawable.getPaint().setColor(badgeColor);
    setBackgroundDrawable(bgDrawable);
  }
Example #20
0
  private ShapeDrawable getDefaultBackground() {

    int r = dipToPixels(DEFAULT_CORNER_RADIUS_DIP);
    float[] outerR = new float[] {r, r, r, r, r, r, r, r};

    RoundRectShape rr = new RoundRectShape(outerR, null, null);
    ShapeDrawable drawable = new ShapeDrawable(rr);
    drawable.getPaint().setColor(badgeColor);

    return drawable;
  }
 private static Drawable generateCircleDrawable(final int color) {
   ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
   drawable.setShaderFactory(
       new ShapeDrawable.ShaderFactory() {
         @Override
         public Shader resize(int width, int height) {
           return new LinearGradient(0, 0, 0, 0, color, color, Shader.TileMode.REPEAT);
         }
       });
   return drawable;
 }
  public PagerHeader(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;

    Resources resources = context.getResources();
    mDisplayMetrics = resources.getDisplayMetrics();

    // Get attributes from the layout xml
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerHeader, 0, 0);
    //		mActiveTextColor = new ColorSet(
    //				a.getColor(R.styleable.PagerHeader_activeTextColor, Color.GREEN));
    mActiveTextColor = new ColorSet(resources.getColor(R.color.cputuner_green));
    mInactiveTextColor =
        new ColorSet(a.getColor(R.styleable.PagerHeader_inactiveTextColor, Color.LTGRAY));
    mTabColor =
        new ColorSet(a.getColor(R.styleable.PagerHeader_tabColor, mActiveTextColor.getColor()));
    mTabHeight = a.getDimensionPixelSize(R.styleable.PagerHeader_tabHeight, dipToPixels(4));
    mTabPadding = a.getDimensionPixelSize(R.styleable.PagerHeader_tabPadding, dipToPixels(10));
    mPaddingPush = a.getDimensionPixelSize(R.styleable.PagerHeader_paddingPush, dipToPixels(50));
    mFadingEdgeLength =
        a.getDimensionPixelSize(R.styleable.PagerHeader_fadingEdgeLength, dipToPixels(30));
    mShowTopShadow = a.getBoolean(R.styleable.PagerHeader_showTopShadow, true);
    mShowBottomBar = a.getBoolean(R.styleable.PagerHeader_showBottomBar, true);
    mShowTab = a.getBoolean(R.styleable.PagerHeader_showTab, true);

    ColorSet fadingEdgeColorHint = new ColorSet(0);
    int backgroundColor = a.getColor(R.styleable.PagerHeader_backgroundColor, Color.DKGRAY);
    setBackgroundColor(backgroundColor);
    fadingEdgeColorHint.setColor(backgroundColor);

    mTabDrawable = new ShapeDrawable(new RectShape());
    mTabDrawable.getPaint().setColor(mTabColor.getColor());

    mBottomBar = new ShapeDrawable(new RectShape());
    mBottomBar.getPaint().setColor(mTabColor.getColor());
    mBottomBarHeight = dipToPixels(2);

    mShadow =
        new GradientDrawable(
            GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x88000000, 0x00000000});
    mShadowHeight = dipToPixels(3);

    int[] fadingEdgeGradient =
        new int[] {fadingEdgeColorHint.getColor(), fadingEdgeColorHint.getColor(0)};
    mFadingEdgeLeft =
        new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, fadingEdgeGradient);
    mFadingEdgeRight =
        new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, fadingEdgeGradient);

    final ViewConfiguration config = ViewConfiguration.get(context);
    int touchSlop = config.getScaledTouchSlop();
    mTouchSlopSquare = touchSlop * touchSlop;
  }
  private Drawable createOuterStrokeDrawable(float strokeWidth) {
    ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

    final Paint paint = shapeDrawable.getPaint();
    paint.setAntiAlias(true);
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(Style.STROKE);
    paint.setColor(Color.BLACK);
    paint.setAlpha(opacityToAlpha(0.02f));

    return shapeDrawable;
  }
Example #24
0
  public PuzzleView(Context context) {
    super(context);

    mDrawable = new ShapeDrawable(new OvalShape());
    int x = 10;
    int y = 10;
    int width = 300;
    int height = 50;

    mDrawable.getPaint().setColor(0xff74AC23);
    mDrawable.setBounds(x, y, x + width, y + height);
  }
Example #25
0
    private void setFakeImage(InputStream input) {
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      BitmapFactory.decodeStream(input, null, options);

      int[] sizes = calculateSize(options.outWidth, options.outHeight);

      ShapeDrawable draw = new ShapeDrawable(new RectShape());
      draw.setBounds(0, 0, sizes[0], sizes[1]);

      setImageSpan(builder, draw, start, end);
    }
  @Override
  public void draw(Canvas c) {
    if (mShadow != null) {
      mShadow.getPaint().setColor(mBackgroundColor);
      mShadow.draw(c);
    }

    final Rect bounds = getBounds();
    final int saveCount = c.save();
    c.rotate(mRotation, bounds.exactCenterX(), bounds.exactCenterY());
    mRing.draw(c, bounds);
    c.restoreToCount(saveCount);
  }
 @Override
 public void onBindSwipeViewHolder(RecyclerView.ViewHolder swipeViewHolder, int i) {
   SampleViewHolder sampleViewHolder = (SampleViewHolder) swipeViewHolder;
   ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
   drawable
       .getPaint()
       .setColor(
           mContext
               .getResources()
               .getColor(colors[((int) (Math.random() * (colors.length - 1)))]));
   sampleViewHolder.avatarView.setBackgroundDrawable(drawable);
   sampleViewHolder.textView.setText(mDataset.get(i));
 }
  @Override
  public void getActionsLayout(Context ctx, final LinearLayout cont) {
    WindowManager mWinMgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
    int displayWidth = mWinMgr.getDefaultDisplay().getWidth();
    cont.removeAllViews();
    final TextView cmd = new TextView(ctx);

    cmd.setText(Html.fromHtml("<b>Reading:</b> " + getOutputCelsius() + "°C"));
    if (prefs.isLightThemeSelected()) cmd.setTextColor(ctx.getResources().getColor(R.color.black));
    RelativeLayout.LayoutParams lp =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    cmd.setLayoutParams(lp);
    lp.setMargins(2, 0, 0, 2);
    // cmd.setGravity(Gravity.TOP);
    cont.addView(cmd);

    ProgressBar par = new ProgressBar(ctx, null, android.R.attr.progressBarStyleHorizontal);
    // ProgressBar sfumata
    final ShapeDrawable pgDrawable =
        new ShapeDrawable(new RoundRectShape(Constants.roundedCorners, null, null));
    final LinearGradient gradient =
        new LinearGradient(
            0,
            0,
            displayWidth / 2,
            0,
            ctx.getResources().getColor(color.aa_blue),
            ctx.getResources().getColor(color.aa_red),
            android.graphics.Shader.TileMode.CLAMP);
    pgDrawable.getPaint().setStrokeWidth(3);
    pgDrawable.getPaint().setDither(true);
    pgDrawable.getPaint().setShader(gradient);

    ClipDrawable progress = new ClipDrawable(pgDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
    par.setProgressDrawable(progress);
    par.setBackgroundResource(android.R.drawable.progress_horizontal);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    lp2.setMargins(2, 2, 4, 2);
    par.setLayoutParams(lp2);
    par.setMax(50);
    par.setProgress(20);
    par.setProgress(0);
    par.setMax(40);
    par.setProgress((int) getOutputFloat());

    cont.addView(par);
  }
  /**
   * 通过绘制Path构建一个ShapeDrawable,用来绘制到画布Canvas上
   *
   * @return
   */
  private ShapeDrawable drawGooView() {
    Path path = new Path();

    // 1. 根据当前两圆圆心的距离计算出固定圆的半径
    float distance = (float) GeometryUtil.getDistanceBetween2Points(mDragCenter, mStickCenter);
    stickCircleTempRadius = getCurrentRadius(distance);

    // 2. 计算出经过两圆圆心连线的垂线的dragLineK(对边比临边)。求出四个交点坐标
    float xDiff = mStickCenter.x - mDragCenter.x;
    Double dragLineK = null;
    if (xDiff != 0) {
      dragLineK = (double) ((mStickCenter.y - mDragCenter.y) / xDiff);
    }

    // 分别获得经过两圆圆心连线的垂线与圆的交点(两条垂线平行,所以dragLineK相等)。
    PointF[] dragPoints =
        GeometryUtil.getIntersectionPoints(mDragCenter, dragCircleRadius, dragLineK);
    PointF[] stickPoints =
        GeometryUtil.getIntersectionPoints(mStickCenter, stickCircleTempRadius, dragLineK);

    // 3. 以两圆连线的0.618处作为 贝塞尔曲线 的控制点。(选一个中间点附近的控制点)
    PointF pointByPercent = GeometryUtil.getPointByPercent(mDragCenter, mStickCenter, 0.618f);

    // 绘制两圆连接
    // 此处参见示意图{@link https://github.com/PoplarTang/DragGooView }
    path.moveTo((float) stickPoints[0].x, (float) stickPoints[0].y);
    path.quadTo(
        (float) pointByPercent.x,
        (float) pointByPercent.y,
        (float) dragPoints[0].x,
        (float) dragPoints[0].y);
    path.lineTo((float) dragPoints[1].x, (float) dragPoints[1].y);
    path.quadTo(
        (float) pointByPercent.x,
        (float) pointByPercent.y,
        (float) stickPoints[1].x,
        (float) stickPoints[1].y);
    path.close();

    // 将四个交点画到屏幕上
    //		path.addCircle((float)dragPoints[0].x, (float)dragPoints[0].y, 5, Direction.CW);
    //		path.addCircle((float)dragPoints[1].x, (float)dragPoints[1].y, 5, Direction.CW);
    //		path.addCircle((float)stickPoints[0].x, (float)stickPoints[0].y, 5, Direction.CW);
    //		path.addCircle((float)stickPoints[1].x, (float)stickPoints[1].y, 5, Direction.CW);

    // 构建ShapeDrawable
    ShapeDrawable shapeDrawable = new ShapeDrawable(new PathShape(path, 50f, 50f));
    shapeDrawable.getPaint().setColor(Color.RED);
    return shapeDrawable;
  }
  @SuppressLint("NewApi")
  private void addBordersToView(LoopMeBannerView bannerView) {
    ShapeDrawable drawable = new ShapeDrawable(new RectShape());
    drawable.getPaint().setColor(Color.BLACK);
    drawable.getPaint().setStyle(Style.FILL_AND_STROKE);
    drawable.getPaint().setAntiAlias(true);

    bannerView.setPadding(2, 2, 2, 2);
    if (Build.VERSION.SDK_INT < 16) {
      bannerView.setBackgroundDrawable(drawable);
    } else {
      bannerView.setBackground(drawable);
    }
  }