Ejemplo n.º 1
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float centerX = this.getWidth() / 2;
    float centerY = this.getHeight() / 2;
    float nHeight = Convertor.convertDpToPixel(19, context);
    float i1 = Convertor.convertDpToPixel(14, context);
    float i2 = Convertor.convertDpToPixel(18, context);
    float dp = Convertor.convertDpToPixel(1, context);
    float h = dp / 2;
    if (h < 1) h = 1;

    Drawable dr = context.getResources().getDrawable(R.drawable.thumb_timebar);
    Drawable dr_new = resize(dr);
    this.setThumb(dr_new);
    Paint p = new Paint();
    p.setColor(colorDisabled);
    canvas.drawRect(
        0,
        this.getHeight() - this.getThumb().getBounds().height() / 2 - 2,
        getWidth(),
        this.getHeight() - this.getThumb().getBounds().height() / 2 + 1,
        p);
    canvas.drawRect(centerX - (2 * h), centerY + i1 / 2, centerX + (2 * h), centerY - i1 / 2, p);
    canvas.drawRect(
        centerX / 3 * 2 - h, centerY + i2 / 2, centerX / 3 * 2 + h, centerY - i2 / 2, p);
    canvas.drawRect(centerX / 3 - h, centerY + i1 / 2, centerX / 3 + h, centerY - i1 / 2, p);
    canvas.drawRect(
        centerX + centerX / 3 - h,
        centerY + i2 / 2,
        centerX + centerX / 3 + h,
        centerY - i2 / 2,
        p);
    canvas.drawRect(
        centerX + centerX / 3 * 2 - h,
        centerY + i1 / 2,
        centerX + centerX / 3 * 2 + h,
        centerY - i1 / 2,
        p);
  }
Ejemplo n.º 2
0
 private Drawable resize(Drawable image) {
   int h = Math.round(Convertor.convertDpToPixel(18, context));
   Bitmap b = ((BitmapDrawable) image).getBitmap();
   Bitmap bitmapResized = Bitmap.createScaledBitmap(b, h, h, false);
   return new BitmapDrawable(getResources(), bitmapResized);
 }