Java Code Examples for android.graphics.Paint.setTextScaleX()

The following are Jave code examples for showing how to use setTextScaleX() of the android.graphics.Paint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: timePicker   File: WheelView.java   View Source Code Vote up 6 votes
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setColor(textColorOut);
    paintOuterText.setAntiAlias(true);
    paintOuterText.setTypeface(Typeface.MONOSPACE);
    paintOuterText.setTextSize(textSize);

    paintCenterText = new Paint();
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setAntiAlias(true);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(Typeface.MONOSPACE);
    paintCenterText.setTextSize(textSize);

    paintIndicator = new Paint();
    paintIndicator.setColor(dividerColor);
    paintIndicator.setAntiAlias(true);

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}
 
Example 2
Project: Android-PickerDialog   File: WheelView.java   View Source Code Vote up 6 votes
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setColor(textColorOut);
    paintOuterText.setAntiAlias(true);
    paintOuterText.setTypeface(Typeface.MONOSPACE);
    paintOuterText.setTextSize(textSize);

    paintCenterText = new Paint();
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setAntiAlias(true);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(Typeface.MONOSPACE);
    paintCenterText.setTextSize(textSize);

    paintIndicator = new Paint();
    paintIndicator.setColor(dividerColor);
    paintIndicator.setAntiAlias(true);

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}
 
Example 3
Project: simple-keyboard   File: MainKeyboardView.java   View Source Code Vote up 6 votes
private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
    final int maxTextWidth = width - mLanguageOnSpacebarHorizontalMargin * 2;
    paint.setTextScaleX(1.0f);
    final float textWidth = TypefaceUtils.getStringWidth(text, paint);
    if (textWidth < width) {
        return true;
    }

    final float scaleX = maxTextWidth / textWidth;
    if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) {
        return false;
    }

    paint.setTextScaleX(scaleX);
    return TypefaceUtils.getStringWidth(text, paint) < maxTextWidth;
}
 
Example 4
Project: xlight_android_native   File: WheelView.java   View Source Code Vote up 6 votes
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setColor(textColorOut);
    paintOuterText.setAntiAlias(true);
    paintOuterText.setTypeface(Typeface.MONOSPACE);
    paintOuterText.setTextSize(textSize);

    paintCenterText = new Paint();
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setAntiAlias(true);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(Typeface.MONOSPACE);
    paintCenterText.setTextSize(textSize);

    paintIndicator = new Paint();
    paintIndicator.setColor(dividerColor);
    paintIndicator.setAntiAlias(true);

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}
 
Example 5
Project: CXJPadProject   File: WheelView.java   View Source Code Vote up 6 votes
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setAntiAlias(true);
    paintOuterText.setColor(textColorOuter);
    paintOuterText.setTypeface(typeface);
    paintOuterText.setTextSize(textSize);
    paintCenterText = new Paint();
    paintCenterText.setAntiAlias(true);
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(typeface);
    paintCenterText.setTextSize(textSize);
    paintIndicator = new Paint();
    paintIndicator.setAntiAlias(true);
    paintIndicator.setColor(dividerConfig.color);
    paintIndicator.setStrokeWidth(dividerConfig.thick);
    paintIndicator.setAlpha(dividerConfig.alpha);
    paintShadow = new Paint();
    paintShadow.setAntiAlias(true);
    paintShadow.setColor(dividerConfig.shadowColor);
    paintShadow.setAlpha(dividerConfig.shadowAlpha);
    setLayerType(LAYER_TYPE_SOFTWARE, null);
}
 
Example 6
Project: AOSP-Kayboard-7.1.2   File: MainKeyboardView.java   View Source Code Vote up 6 votes
private boolean fitsTextIntoWidth(final int width, final String text, final Paint paint) {
    final int maxTextWidth = width - mLanguageOnSpacebarHorizontalMargin * 2;
    paint.setTextScaleX(1.0f);
    final float textWidth = TypefaceUtils.getStringWidth(text, paint);
    if (textWidth < width) {
        return true;
    }

    final float scaleX = maxTextWidth / textWidth;
    if (scaleX < MINIMUM_XSCALE_OF_LANGUAGE_NAME) {
        return false;
    }

    paint.setTextScaleX(scaleX);
    return TypefaceUtils.getStringWidth(text, paint) < maxTextWidth;
}
 
Example 7
Project: RLibrary   File: WheelView.java   View Source Code Vote up 6 votes
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setColor(textColorOut);
    paintOuterText.setAntiAlias(true);
    paintOuterText.setTypeface(typeface);
    paintOuterText.setTextSize(textSize);

    paintCenterText = new Paint();
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setAntiAlias(true);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(typeface);
    paintCenterText.setTextSize(textSize);


    paintIndicator = new Paint();
    paintIndicator.setColor(dividerColor);
    paintIndicator.setAntiAlias(true);

    if (android.os.Build.VERSION.SDK_INT >= 11) {
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
}
 
Example 8
Project: simple-keyboard   File: MainKeyboardView.java   View Source Code Vote up 5 votes
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
Example 9
Project: SmingZZick_App   File: TextMakingInfo.java   View Source Code Vote up 5 votes
public Paint getPaint(Context context, float scale, boolean outline) {
    float textSize = TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            this.textSize,
            context.getResources().getDisplayMetrics()) * scale;

    Paint textPaint = new Paint();

    if (typeface != null) {
        textPaint.setTypeface(typeface);
    }

    textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    textPaint.setTextSize(textSize);
    textPaint.setAntiAlias(true);

    if (outline == false) {
        textPaint.setStrokeWidth(textSize * textStrokeRatio);
        textPaint.setColor(textColor);
    } else {
        textPaint.setStrokeWidth(textSize * textStrokeRatio + textSize * textOutlineRatio);
        textPaint.setColor(outlineColor);
    }


    // skew
    textPaint.setTextSkewX(skewX);


    // scaleX
    textPaint.setTextScaleX(scaleX);

    if (Build.VERSION.SDK_INT >= 21) {
        textPaint.setLetterSpacing(letterSpacing);
    }

    return textPaint;
}
 
Example 10
Project: AOSP-Kayboard-7.1.2   File: MainKeyboardView.java   View Source Code Vote up 5 votes
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
Example 11
Project: starcor.xul   File: XulBasicTextRenderer.java   View Source Code Vote up 5 votes
protected Paint _getTextPaint(float fontSizeScale) {
	XulRenderContext ctx = _render.getRenderContext();
	Paint defPaint = ctx.getTextPaintByName(_fontFace);

	if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
		defPaint = ctx.getShadowTextPaintByName(_fontFace);
		defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
	}

	defPaint.setColor(_fontColor);
	if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
		defPaint.setTextSize(_fontSize * fontSizeScale);
	} else {
		defPaint.setTextSize(_fontSize);
	}

	if (_fontWeight > 1.0) {
		if (_fontWeight > 2.5) {
			defPaint.setStrokeWidth(_fontWeight*fontSizeScale/2);
		} else {
			defPaint.setFakeBoldText(true);
		}
	} else {
		defPaint.setFakeBoldText(false);
	}
	defPaint.setTextScaleX(_fontScaleX);
	defPaint.setUnderlineText(_fontUnderline);
	defPaint.setStrikeThruText(_fontStrikeThrough);
	defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
	defPaint.setTextAlign(Paint.Align.LEFT);
	return defPaint;
}