draw Text Bound on Canvas - Android Graphics

Android examples for Graphics:Canvas

Description

draw Text Bound on Canvas

Demo Code


//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Canvas;
import android.graphics.Color;

import android.graphics.DashPathEffect;

import android.graphics.Paint;

import android.graphics.PathEffect;

import android.graphics.RectF;

public class Main {

    public static void drawTextBound(RectF rect, Bitmap bitmap) {
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.WHITE);
        paint.setStrokeWidth(5);//w ww .j av  a2s  .c o m
        PathEffect effects = new DashPathEffect(new float[] { 5, 5, 5, 5 },
                1);
        paint.setPathEffect(effects);
        canvas.drawRect(rect, paint);
    }
}

Related Tutorials