Android Canvas.drawText

Worked this out, turns out that android.R.color.black is not the same as Color.BLACK. Changed the code to: Paint paint = new Paint(); paint.setColor(Color.WHITE); paint.setStyle(Style.FILL); canvas.drawPaint(paint); paint.setColor(Color.BLACK); paint.setTextSize(20); canvas.drawText(“Some Text”, 10, 25, paint); and it all works fine now!!

Creating an empty bitmap and drawing though canvas in Android

This is probably simpler than you’re thinking: int w = WIDTH_PX, h = HEIGHT_PX; Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap Canvas canvas = new Canvas(bmp); // ready to draw on that bitmap through that canvas Here’s the official documentation on … Read more

Draw in Canvas by finger, Android

Start By going through the Fingerpaint demo in the sdk sample. Another Sample: public class MainActivity extends Activity { DrawingView dv ; private Paint mPaint; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dv = new DrawingView(this); setContentView(dv); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(Color.GREEN); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStrokeWidth(12); } public class DrawingView extends View { … Read more

Draw multi-line text to Canvas

I found another way using static layouts. The code is here for anyone to refer to: TextPaint mTextPaint=new TextPaint(); StaticLayout mTextLayout = new StaticLayout(mText, mTextPaint, canvas.getWidth(), Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); canvas.save(); // calculate x and y position where your text will be placed textX = … textY = … canvas.translate(textX, textY); mTextLayout.draw(canvas); canvas.restore();

Measuring text height to be drawn on Canvas ( Android )

There are different ways to measure the height depending on what you need. #1 getTextBounds If you are doing something like precisely centering a small amount of fixed text, you probably want getTextBounds. You can get the bounding rectangle like this Rect bounds = new Rect(); mTextPaint.getTextBounds(mText, 0, mText.length(), bounds); int height = bounds.height(); As … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)