Example usage for android.graphics Paint ANTI_ALIAS_FLAG

List of usage examples for android.graphics Paint ANTI_ALIAS_FLAG

Introduction

In this page you can find the example usage for android.graphics Paint ANTI_ALIAS_FLAG.

Prototype

int ANTI_ALIAS_FLAG

To view the source code for android.graphics Paint ANTI_ALIAS_FLAG.

Click Source Link

Document

Paint flag that enables antialiasing when drawing.

Usage

From source file:com.aniruddhc.acemusic.player.GridViewFragment.GridViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_grid_view, container, false);
    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;/* w  ww .  j  a v  a  2  s .co m*/
    mFragment = this;

    //Set the background color and the partial color bleed.
    mRootView.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    //Grab the fragment. This will determine which data to load into the cursor.
    mFragmentId = getArguments().getInt(Common.FRAGMENT_ID);
    mFragmentTitle = getArguments().getString(MainActivity.FRAGMENT_HEADER);
    mDBColumnsMap = new HashMap<Integer, String>();

    mQuickScroll = (QuickScrollGridView) mRootView.findViewById(R.id.quickscrollgrid);

    //Set the adapter for the outer gridview.
    mGridView = (GridView) mRootView.findViewById(R.id.generalGridView);
    mGridViewContainer = (RelativeLayout) mRootView.findViewById(R.id.fragment_grid_view_frontal_layout);
    mGridView.setVerticalScrollBarEnabled(false);

    //Set the number of gridview columns based on the screen density and orientation.
    if (mApp.isPhoneInLandscape() || mApp.isTabletInLandscape()) {
        mGridView.setNumColumns(4);
    } else if (mApp.isPhoneInPortrait()) {
        mGridView.setNumColumns(2);
    } else if (mApp.isTabletInPortrait()) {
        mGridView.setNumColumns(3);
    }

    //KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int topPadding = Common.getStatusBarHeight(mContext);

        //Calculate navigation bar height.
        int navigationBarHeight = 0;
        int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
        }

        mGridViewContainer.setPadding(0, topPadding, 0, 0);
        mGridView.setClipToPadding(false);
        mGridView.setPadding(0, mGridView.getPaddingTop(), 0, navigationBarHeight);
        mQuickScroll.setPadding(0, 0, 0, navigationBarHeight);

    }

    //Set the empty views.
    mEmptyTextView = (TextView) mRootView.findViewById(R.id.empty_view_text);
    mEmptyTextView.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Light"));
    mEmptyTextView
            .setPaintFlags(mEmptyTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    //Create a set of options to optimize the bitmap memory usage.
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    options.inJustDecodeBounds = false;
    options.inPurgeable = true;

    mHandler.postDelayed(queryRunnable, 250);
    return mRootView;
}

From source file:com.nextgis.maplibui.overlay.EditLayerOverlay.java

public EditLayerOverlay(Context context, MapViewOverlays mapViewOverlays) {
    super(context, mapViewOverlays);
    mLayer = null;/*from ww  w. j  a  v a 2s .  co  m*/
    mMode = MODE_NONE;

    mTolerancePX = context.getResources().getDisplayMetrics().density * ConstantsUI.TOLERANCE_DP;

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.RED);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(LINE_WIDTH / 2);

    mDrawItems = new ArrayList<>();
    mListeners = new ArrayList<>();

    mMap = mMapViewOverlays.getMap();
    mMapViewOverlays.addListener(this);
    mOverlayPoint = new OverlayItem(mMap, 0, 0, getMarker());
    DrawItem.init(context);
}

From source file:am.widget.indicatortabstrip.IndicatorTabStrip.java

public IndicatorTabStrip(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setItemClickable(true);/*ww  w.j a  v a2  s .c  o m*/
    setClickSmoothScroll(true);
    final float density = getResources().getDisplayMetrics().density;
    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextAlign(Align.CENTER);
    if (Build.VERSION.SDK_INT > 4) {
        updateTextPaintDensity();
    }
    mTagLocation = new TagLocation(TagLocation.LOCATION_EDGE);
    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    int n = a.getIndexCount();
    int textSize = (int) (DEFAULT_TEXT_SIZE * density);
    ColorStateList textColors = null;
    Drawable divider = null;
    for (int i = 0; i < n; i++) {
        int attr = a.getIndex(i);
        switch (attr) {
        case 0:
            textSize = a.getDimensionPixelSize(attr, textSize);
            break;
        case 1:
            textColors = a.getColorStateList(attr);
            break;
        case 2:
            divider = a.getDrawable(attr);
            break;
        }
    }
    a.recycle();
    float scale = 1;
    Drawable itemBackground = null;
    ColorStateList gradient = null;
    Drawable indicator = null;
    int indicatorWidthMode = INDICATOR_WIDTH_MODE_SET;
    int indicatorPadding = 0;
    int indicatorWidth = INDICATOR_WIDTH_BY_DRAWABLE;
    int indicatorHeight = INDICATOR_HEIGHT_BY_DRAWABLE;
    Drawable interval = null;
    int minItemWidth = (int) (DEFAULT_ITEM_WIDTH * density);
    int minItemHeight = (int) (DEFAULT_ITEM_HEIGHT * density);
    int tagTextSize = (int) (DEFAULT_TAG_TEXT_SIZE * density);
    int tagTextColor = DEFAULT_TAG_TEXT_COLOR;
    Drawable tagBackground = getDefaultTagBackground();
    int tagMinSizeMode = TAG_MIN_SIZE_MODE_HAS_TEXT;
    int tagMinWidth = (int) (DEFAULT_TAG_MIN_SIZE * density);
    int tagMinHeight = (int) (DEFAULT_TAG_MIN_SIZE * density);
    int tagPaddingLeft = 0;
    int tagPaddingTop = 0;
    int tagPaddingRight = 0;
    int tagPaddingBottom = 0;
    int tagMarginLeft = 0;
    int tagMarginTop = 0;
    int tagMarginRight = 0;
    int tagMarginBottom = 0;
    TypedArray custom = context.obtainStyledAttributes(attrs, R.styleable.IndicatorTabStrip);
    textSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTextSize, textSize);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTextColor))
        textColors = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsTextColor);
    scale = custom.getFloat(R.styleable.IndicatorTabStrip_ttsTextScale, scale);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsBackground))
        itemBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsBackground);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsGradient))
        gradient = custom.getColorStateList(R.styleable.IndicatorTabStrip_ttsGradient);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsDivider))
        divider = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsDivider);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsIndicator))
        indicator = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsIndicator);
    indicatorWidthMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsIndicatorWidthMode, indicatorWidthMode);
    indicatorPadding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorPadding,
            indicatorPadding);
    indicatorWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorWidth,
            indicatorWidth);
    indicatorHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsIndicatorHeight,
            indicatorHeight);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsInterval))
        interval = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsInterval);
    minItemWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemWidth, minItemWidth);
    minItemHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsMinItemHeight,
            minItemHeight);
    tagTextSize = custom.getDimensionPixelSize(R.styleable.IndicatorTabStrip_ttsTagTextSize, tagTextSize);
    tagTextColor = custom.getColor(R.styleable.IndicatorTabStrip_ttsTagTextColor, tagTextColor);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagBackground))
        tagBackground = custom.getDrawable(R.styleable.IndicatorTabStrip_ttsTagBackground);
    tagMinSizeMode = custom.getInt(R.styleable.IndicatorTabStrip_ttsTagMinSizeMode, tagMinSizeMode);
    tagMinWidth = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinWidth, tagMinWidth);
    tagMinHeight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMinHeight, tagMinHeight);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagPadding)) {
        final int padding = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPadding, 0);
        tagPaddingLeft = padding;
        tagPaddingTop = padding;
        tagPaddingRight = padding;
        tagPaddingBottom = padding;
    }
    tagPaddingLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingLeft,
            tagPaddingLeft);
    tagPaddingTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingTop,
            tagPaddingTop);
    tagPaddingRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingRight,
            tagPaddingRight);
    tagPaddingBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagPaddingBottom,
            tagPaddingBottom);
    if (custom.hasValue(R.styleable.IndicatorTabStrip_ttsTagMargin)) {
        final int margin = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMargin, 0);
        tagMarginLeft = margin;
        tagMarginTop = margin;
        tagMarginRight = margin;
        tagMarginBottom = margin;
    }
    tagMarginLeft = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginLeft,
            tagMarginLeft);
    tagMarginTop = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginTop, tagMarginTop);
    tagMarginRight = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginRight,
            tagMarginRight);
    tagMarginBottom = custom.getDimensionPixelOffset(R.styleable.IndicatorTabStrip_ttsTagMarginBottom,
            tagMarginBottom);
    custom.recycle();
    setTextSize(textSize);
    if (textColors != null) {
        setTextColor(textColors);
    } else {
        setTextColor(DEFAULT_TEXT_COLOR);
    }
    setTextScale(scale);
    setItemBackground(itemBackground);
    setGradient(gradient);
    setDivider(divider);
    setIndicator(indicator);
    setIndicatorWidthMode(indicatorWidthMode);
    setIndicatorPadding(indicatorPadding);
    setIndicatorWidth(indicatorWidth);
    setIndicatorHeight(indicatorHeight);
    setInterval(interval);
    setMinItemWidth(minItemWidth);
    setMinItemHeight(minItemHeight);
    setTagTextSize(tagTextSize);
    setTagTextColor(tagTextColor);
    setTagBackground(tagBackground);
    setTagMinSizeMode(tagMinSizeMode);
    setTagMinWidth(tagMinWidth);
    setTagMinHeight(tagMinHeight);
    setTagPadding(tagPaddingLeft, tagPaddingTop, tagPaddingRight, tagPaddingBottom);
    setTagMargin(tagMarginLeft, tagMarginTop, tagMarginRight, tagMarginBottom);
}

From source file:com.android.settings.widget.DotsPageIndicator.java

public DotsPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    final int scaledDensity = (int) context.getResources().getDisplayMetrics().scaledDensity;

    // Load attributes
    final TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.DotsPageIndicator,
            defStyle, 0);/*from   w  w w . j a  v a2  s  .  c o m*/
    dotDiameter = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * scaledDensity);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = typedArray.getDimensionPixelSize(R.styleable.DotsPageIndicator_dotGap, DEFAULT_GAP * scaledDensity);
    animDuration = (long) typedArray.getInteger(R.styleable.DotsPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = typedArray.getColor(R.styleable.DotsPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);
    typedArray.recycle();
    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = loadInterpolator(context, android.R.interpolator.fast_out_slow_in);
    } else {
        interpolator = loadInterpolator(context, android.R.anim.accelerate_decelerate_interpolator);
    }

    // create paths & rect now  reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
        @Override
        public void onViewAttachedToWindow(View v) {
            attachedState = true;
        }

        @Override
        public void onViewDetachedFromWindow(View v) {
            attachedState = false;
        }
    });
}

From source file:com.forrestguice.suntimeswidget.LightMapView.java

/**
 * @param data an instance of SuntimesRiseSetDataset
 *///from  w  w  w.jav  a2  s. c  o  m
public void updateViews(SuntimesRiseSetDataset data) {
    this.data = data;
    int w = getWidth();
    int h = getHeight();

    if (mainView != null && w > 0 && h > 0) {
        long bench_start = System.nanoTime();
        Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
        Canvas c = new Canvas(b);
        Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);

        boolean layer_astro, layer_nautical, layer_civil;

        // draw background (night)
        p.setColor(colorNight);
        drawRect(c, p);

        if (data != null) {
            // draw astro twilight
            p.setColor(colorAstro);
            if (!(layer_astro = drawRect(data.dataAstro, c, p))) {
                if (data.dataNautical.hasSunriseTimeToday() || data.dataNautical.hasSunsetTimeToday()) {
                    drawRect(c, p);
                }
            }

            // draw nautical twilight
            p.setColor(colorNautical);
            if (!(layer_nautical = drawRect(data.dataNautical, c, p))) {
                if (data.dataCivil.hasSunriseTimeToday() || data.dataCivil.hasSunsetTimeToday()) {
                    drawRect(c, p);
                }
            }

            // draw civil twilight
            p.setColor(colorCivil);
            if (!(layer_civil = drawRect(data.dataCivil, c, p))) {
                if (data.dataActual.hasSunriseTimeToday() || data.dataActual.hasSunsetTimeToday()) {
                    drawRect(c, p);
                }
            }

            // draw foreground (day)
            p.setColor(colorDay);
            if (!drawRect(data.dataActual, c, p)) {
                boolean noLayers = !layer_astro && !layer_nautical && !layer_civil;
                if (noLayers && data.isDay()) {
                    drawRect(c, p);
                }
            }

            // draw now marker
            drawPoint(data.now(), pointRadius, c, p);
        }

        mainView.setImageBitmap(b);
        lastUpdate = System.currentTimeMillis();
        long bench_end = System.nanoTime();
        Log.d("DEBUG", "lightmap updated in " + ((bench_end - bench_start) / 1000000.0) + "ms :: " + w + "," + h
                + " :: hasView: " + (mainView != null) + " :: hasData " + (data != null));
    }
}

From source file:net.droidsolutions.droidcharts.core.plot.Marker.java

/**
 * Constructs a new marker./*from   www .j  a  v  a 2s . c  o  m*/
 * 
 * @param paint
 *            the paint (<code>null</code> not permitted).
 * @param stroke
 *            the stroke (<code>null</code> not permitted).
 * @param outlinePaint
 *            the outline paint (<code>null</code> permitted).
 * @param outlineStroke
 *            the outline stroke (<code>null</code> permitted).
 * @param alpha
 *            the alpha transparency (must be in the range 0.0f to 1.0f).
 * 
 * @throws IllegalArgumentException
 *             if <code>paint</code> or <code>stroke</code> is
 *             <code>null</code>, or <code>alpha</code> is not in the
 *             specified range.
 */
protected Marker(int paint, float stroke, int outlinePaint, float outlineStroke, int alpha) {

    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setColor(paint);
    this.paint = p;
    this.stroke = stroke;
    p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setColor(outlinePaint);
    this.outlinePaint = p;
    this.outlineStroke = outlineStroke;
    this.alpha = alpha;

    this.labelFont = new Font("SansSerif", Typeface.NORMAL, 9);
    p = new Paint(Paint.ANTI_ALIAS_FLAG);
    p.setColor(Color.BLACK);
    this.labelPaint = p;
    this.labelAnchor = RectangleAnchor.TOP_LEFT;
    this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0);
    this.labelOffsetType = LengthAdjustmentType.CONTRACT;
    this.labelTextAnchor = TextAnchor.CENTER;

}

From source file:com.seek.ruler.SimpleRulerView.java

/**
 * set default//w  ww. j a v a2s  .  c o m
 * 
 * @param attrs
 */
private void init(AttributeSet attrs) {
    DisplayMetrics dm = getResources().getDisplayMetrics();
    mIntervalDis = dm.density * 5;

    mRulerLineWidth = dm.density * 2;
    mTextSize = dm.scaledDensity * 14;

    TypedArray typedArray = attrs == null ? null
            : getContext().obtainStyledAttributes(attrs, R.styleable.simpleRulerView);
    if (typedArray != null) {
        mHighlightColor = typedArray.getColor(R.styleable.simpleRulerView_highlightColor, mHighlightColor);
        mTextColor = typedArray.getColor(R.styleable.simpleRulerView_textColor, mTextColor);
        mRulerColor = typedArray.getColor(R.styleable.simpleRulerView_rulerColor, mRulerColor);
        mIntervalValue = typedArray.getFloat(R.styleable.simpleRulerView_intervalValue, mIntervalValue);
        mMaxValue = typedArray.getFloat(R.styleable.simpleRulerView_maxValue, mMaxValue);
        mMinValue = typedArray.getFloat(R.styleable.simpleRulerView_minValue, mMinValue);
        mTextSize = typedArray.getDimension(R.styleable.simpleRulerView_textSize, mTextSize);
        mRulerLineWidth = typedArray.getDimension(R.styleable.simpleRulerView_rulerLineWidth, mRulerLineWidth);
        mIntervalDis = typedArray.getDimension(R.styleable.simpleRulerView_intervalDistance, mIntervalDis);
        retainLength = typedArray.getInteger(R.styleable.simpleRulerView_retainLength, 0);
    }

    calculateTotal();

    mRulerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mRulerPaint.setStrokeWidth(mRulerLineWidth);

    mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setTextSize(mTextSize);

    mGestureDetectorCompat = new GestureDetectorCompat(getContext(), this);
    mScroller = new OverScroller(getContext(), new DecelerateInterpolator());

    setSelectedIndex(0);
}

From source file:android.support.v17.leanback.app.ErrorSupportFragment.java

private static FontMetricsInt getFontMetricsInt(TextView textView) {
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setTextSize(textView.getTextSize());
    paint.setTypeface(textView.getTypeface());
    return paint.getFontMetricsInt();
}

From source file:com.cosmicsubspace.nerdyaudio.visuals.PlayControlsView.java

public PlayControlsView(Context context, AttributeSet attrs) {
    super(context, attrs);
    pt = new Paint(Paint.ANTI_ALIAS_FLAG);
    density = getResources().getDisplayMetrics().density;
    qm = QueueManager.getInstance();//from  www. j  a v a 2 s  .com
    ap = AudioPlayer.getInstance();

    Resources res = getResources();
    menuColor = getResources().getColor(R.color.colorPrimary);
    buttonColor = Color.WHITE;
    textPrimary = getResources().getColor(R.color.colorLightPrimaryText);
    textSecondary = getResources().getColor(R.color.colorLightSecondaryText);

    playedColor = ColorFiddler.setAlpha(res.getColor(R.color.colorPrimary), 200);
    //Log2.log(2,this,Color.alpha(playedColor),Color.red(playedColor),Color.blue(playedColor),Color.green(playedColor));
    remainingColor = ColorFiddler.setAlpha(res.getColor(R.color.colorPrimary), 100);

    playedColorEX = ColorFiddler.setAlpha(res.getColor(R.color.colorAccentFallbackDark), 255);
    remainingColorEX = ColorFiddler.setAlpha(res.getColor(R.color.colorAccent), 255);
    //We need to disable hardware acceleration for this layer,
    //since we need to fiddle with blending and shader combining
    //for the marquee text effect.
    //It also takes care of a bug with Paths.
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);

    prepareLayout();

    inst = this;

    refreshPlaying();
}

From source file:github.daneren2005.dsub.util.ImageLoader.java

private Bitmap createUnknownImage(int size, int primaryColor, String topText, String bottomText) {
    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    Paint color = new Paint();
    color.setColor(primaryColor);/*from  w w  w . j  a v a  2  s  .c  o m*/
    canvas.drawRect(0, 0, size, size * 2.0f / 3.0f, color);

    color.setShader(new LinearGradient(0, 0, 0, size / 3.0f, Color.rgb(82, 82, 82), Color.BLACK,
            Shader.TileMode.MIRROR));
    canvas.drawRect(0, size * 2.0f / 3.0f, size, size, color);

    if (topText != null || bottomText != null) {
        Paint font = new Paint();
        font.setFlags(Paint.ANTI_ALIAS_FLAG);
        font.setColor(Color.WHITE);
        font.setTextSize(3.0f + size * 0.07f);

        if (topText != null) {
            canvas.drawText(topText, size * 0.05f, size * 0.6f, font);
        }

        if (bottomText != null) {
            canvas.drawText(bottomText, size * 0.05f, size * 0.8f, font);
        }
    }

    return bitmap;
}