1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.ui;
6 import android.content.Context;
7 import android.graphics.Canvas;
8 import android.graphics.Color;
9 import android.graphics.Paint;
10 import android.graphics.Paint.Style;
11 import android.util.AttributeSet;
12 import android.widget.Button;
15 * Simple class that draws a white border around a button, purely for a UI change.
17 public class ColorPickerMoreButton extends Button {
19 // A cache for the paint used to draw the border, so it doesn't have to be created in
20 // every onDraw() call.
21 private Paint mBorderPaint;
23 public ColorPickerMoreButton(Context context, AttributeSet attrs) {
24 super(context, attrs);
28 public ColorPickerMoreButton(Context context, AttributeSet attrs, int defStyle) {
29 super(context, attrs, defStyle);
34 * Sets up the paint to use for drawing the border.
37 mBorderPaint = new Paint();
38 mBorderPaint.setStyle(Paint.Style.STROKE);
39 mBorderPaint.setColor(Color.WHITE);
40 // Set the width to one pixel.
41 mBorderPaint.setStrokeWidth(1.0f);
42 // And make sure the border doesn't bleed into the outside.
43 mBorderPaint.setAntiAlias(false);
47 * Draws the border around the edge of the button.
49 * @param canvas The canvas to draw on.
52 protected void onDraw(Canvas canvas) {
53 canvas.drawRect(0.5f, 0.5f, getWidth() - 1.5f, getHeight() - 1.5f, mBorderPaint);