Example #1
0
        void drawCenter(string text, float yMultiply)
        {
            var r = new android.graphics.Rect();

            frameCanvas.getClipBounds(r);
            paint.setTextAlign(android.graphics.Paint.Align.LEFT);
            paint.getTextBounds(text, 0, text.Length, r);
            float x = frameWidth / 2f - r.width() / 2f - r.left;
            float y = frameHeight / 2f + (r.height() * yMultiply) / 2f - r.bottom;

            frameCanvas.drawText(text, x, y, paint);
        }
Example #2
0
 public override int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm)
 {
     LOCAL_PAINT.set(paint);
     applyCustomTypeFace(LOCAL_PAINT, type);
     LOCAL_PAINT.getTextBounds(icon, 0, 1, TEXT_BOUNDS);
     if (fm != null)
     {
         fm.descent = (int)(TEXT_BOUNDS.height() * BASELINE_RATIO);
         fm.ascent  = -(TEXT_BOUNDS.height() - fm.descent);
         fm.top     = fm.ascent;
         fm.bottom  = fm.descent;
     }
     return(TEXT_BOUNDS.width());
 }
Example #3
0
        public override void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint)
        {
            applyCustomTypeFace(paint, type);
            paint.getTextBounds(icon, 0, 1, TEXT_BOUNDS);
            canvas.save();
            if (rotate)
            {
                float rotation = (DateTimeHelperClass.CurrentUnixTimeMillis() - rotationStartTime) / (float)ROTATION_DURATION * 360f;
                float centerX  = x + TEXT_BOUNDS.width() / 2f;
                float centerY  = y - TEXT_BOUNDS.height() / 2f + TEXT_BOUNDS.height() * BASELINE_RATIO;
                canvas.rotate(rotation, centerX, centerY);
            }

            canvas.drawText(icon, x - TEXT_BOUNDS.left, y - TEXT_BOUNDS.bottom + TEXT_BOUNDS.height() * BASELINE_RATIO, paint);
            canvas.restore();
        }