當前位置: 首頁>>代碼示例>>Java>>正文


Java Paint.Align方法代碼示例

本文整理匯總了Java中android.graphics.Paint.Align方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.Align方法的具體用法?Java Paint.Align怎麽用?Java Paint.Align使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.Align方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: textAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public PCanvas textAlign(String alignTo) {
    Paint.Align alignment = Paint.Align.LEFT;

    switch (alignTo) {
        case "left":
            alignment = Paint.Align.LEFT;
            break;

        case "center":
            alignment = Paint.Align.CENTER;
            break;

        case "right":
            alignment = Paint.Align.RIGHT;
            break;
    }

    mPaintFill.setTextAlign(alignment);
    mPaintStroke.setTextAlign(alignment);

    return this;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:23,代碼來源:PCanvas.java

示例2: drawText

import android.graphics.Paint; //導入方法依賴的package包/類
private void drawText(Canvas canvas, float textSize, Paint.Align align, int color, int alpha,
        String value, float x, float y, float dx, float dy) {
    // Draw text with shadow
    mTextPaint.setTextSize(textSize);
    mTextPaint.setTextAlign(align);
    mTextPaint.setColor(Color.BLACK);
    if (alpha < 255) mTextPaint.setAlpha(alpha);
    canvas.drawText(value, x + dx, y + dy, mTextPaint);
    mTextPaint.setColor(color);
    if (alpha < 255) mTextPaint.setAlpha(alpha);
    canvas.drawText(value, x, y, mTextPaint);
}
 
開發者ID:dftec-es,項目名稱:planetcon,代碼行數:13,代碼來源:GalaxyView.java

示例3: drawXAxisValue

import android.graphics.Paint; //導入方法依賴的package包/類
public static void drawXAxisValue(Canvas c, String text, float x, float y,
                                  Paint paint,
                                  MPPointF anchor, float angleDegrees) {

    float drawOffsetX = 0.f;
    float drawOffsetY = 0.f;

    final float lineHeight = paint.getFontMetrics(mFontMetricsBuffer);
    paint.getTextBounds(text, 0, text.length(), mDrawTextRectBuffer);

    // Android sometimes has pre-padding
    drawOffsetX -= mDrawTextRectBuffer.left;

    // Android does not snap the bounds to line boundaries,
    //  and draws from bottom to top.
    // And we want to normalize it.
    drawOffsetY += -mFontMetricsBuffer.ascent;

    // To have a consistent point of reference, we always draw left-aligned
    Paint.Align originalTextAlign = paint.getTextAlign();
    paint.setTextAlign(Paint.Align.LEFT);

    if (angleDegrees != 0.f) {

        // Move the text drawing rect in a way that it always rotates around its center
        drawOffsetX -= mDrawTextRectBuffer.width() * 0.5f;
        drawOffsetY -= lineHeight * 0.5f;

        float translateX = x;
        float translateY = y;

        // Move the "outer" rect relative to the anchor, assuming its centered
        if (anchor.x != 0.5f || anchor.y != 0.5f) {
            final FSize rotatedSize = getSizeOfRotatedRectangleByDegrees(
                    mDrawTextRectBuffer.width(),
                    lineHeight,
                    angleDegrees);

            translateX -= rotatedSize.width * (anchor.x - 0.5f);
            translateY -= rotatedSize.height * (anchor.y - 0.5f);
            FSize.recycleInstance(rotatedSize);
        }

        c.save();
        c.translate(translateX, translateY);
        c.rotate(angleDegrees);

        c.drawText(text, drawOffsetX, drawOffsetY, paint);

        c.restore();
    } else {
        if (anchor.x != 0.f || anchor.y != 0.f) {

            drawOffsetX -= mDrawTextRectBuffer.width() * anchor.x;
            drawOffsetY -= lineHeight * anchor.y;
        }

        drawOffsetX += x;
        drawOffsetY += y;

        c.drawText(text, drawOffsetX, drawOffsetY, paint);
    }

    paint.setTextAlign(originalTextAlign);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:66,代碼來源:Utils.java

示例4: drawMultilineText

import android.graphics.Paint; //導入方法依賴的package包/類
public static void drawMultilineText(Canvas c, StaticLayout textLayout,
                                     float x, float y,
                                     TextPaint paint,
                                     MPPointF anchor, float angleDegrees) {

    float drawOffsetX = 0.f;
    float drawOffsetY = 0.f;
    float drawWidth;
    float drawHeight;

    final float lineHeight = paint.getFontMetrics(mFontMetricsBuffer);

    drawWidth = textLayout.getWidth();
    drawHeight = textLayout.getLineCount() * lineHeight;

    // Android sometimes has pre-padding
    drawOffsetX -= mDrawTextRectBuffer.left;

    // Android does not snap the bounds to line boundaries,
    //  and draws from bottom to top.
    // And we want to normalize it.
    drawOffsetY += drawHeight;

    // To have a consistent point of reference, we always draw left-aligned
    Paint.Align originalTextAlign = paint.getTextAlign();
    paint.setTextAlign(Paint.Align.LEFT);

    if (angleDegrees != 0.f) {

        // Move the text drawing rect in a way that it always rotates around its center
        drawOffsetX -= drawWidth * 0.5f;
        drawOffsetY -= drawHeight * 0.5f;

        float translateX = x;
        float translateY = y;

        // Move the "outer" rect relative to the anchor, assuming its centered
        if (anchor.x != 0.5f || anchor.y != 0.5f) {
            final FSize rotatedSize = getSizeOfRotatedRectangleByDegrees(
                    drawWidth,
                    drawHeight,
                    angleDegrees);

            translateX -= rotatedSize.width * (anchor.x - 0.5f);
            translateY -= rotatedSize.height * (anchor.y - 0.5f);
            FSize.recycleInstance(rotatedSize);
        }

        c.save();
        c.translate(translateX, translateY);
        c.rotate(angleDegrees);

        c.translate(drawOffsetX, drawOffsetY);
        textLayout.draw(c);

        c.restore();
    } else {
        if (anchor.x != 0.f || anchor.y != 0.f) {

            drawOffsetX -= drawWidth * anchor.x;
            drawOffsetY -= drawHeight * anchor.y;
        }

        drawOffsetX += x;
        drawOffsetY += y;

        c.save();

        c.translate(drawOffsetX, drawOffsetY);
        textLayout.draw(c);

        c.restore();
    }

    paint.setTextAlign(originalTextAlign);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:77,代碼來源:Utils.java

示例5: getAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public Paint.Align getAlign() {
	return align;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:PercentStyle.java

示例6: setAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public void setAlign(Paint.Align align) {
	this.align = align;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:PercentStyle.java

示例7: setTitleTextAlign

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Sets the paint alignment that draws the title.
 * @param align {@link android.graphics.Paint.Align}
 */
public void setTitleTextAlign(Paint.Align align) {
    this.titlePaint.setTextAlign(align);
    invalidateConfig();
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:9,代碼來源:ImageTextStateDisplay.java

示例8: setSubtitleTextAlign

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Sets the paint alignment that draws the subtitle.
 * @param align {@link android.graphics.Paint.Align}
 */
public void setSubtitleTextAlign(Paint.Align align) {
    this.subtitlePaint.setTextAlign(align);
    invalidateConfig();
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:9,代碼來源:ImageTextStateDisplay.java

示例9: setTitleTextAlign

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Sets the paint alignment that draws the title.
 * @param align {@link android.graphics.Paint.Align}
 */
public void setTitleTextAlign(Paint.Align align) {
    this.titlePaint.setTextAlign(align);
    invalidateText();
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:9,代碼來源:TextStateDisplay.java

示例10: setSubtitleTextAlign

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Sets the paint alignment that draws the subtitle.
 * @param align {@link android.graphics.Paint.Align}
 */
public void setSubtitleTextAlign(Paint.Align align) {
    this.subtitlePaint.setTextAlign(align);
    invalidateText();
}
 
開發者ID:tylersuehr7,項目名稱:empty-state-recyclerview,代碼行數:9,代碼來源:TextStateDisplay.java

示例11: getAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public Paint.Align getAlign() {
    return align;
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:4,代碼來源:PercentStyle.java

示例12: setAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public void setAlign(Paint.Align align) {
    this.align = align;
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:4,代碼來源:PercentStyle.java

示例13: onClick

import android.graphics.Paint; //導入方法依賴的package包/類
@Override
public void onClick(View v) {
    Paint.Align align = (Paint.Align) v.getTag();
    textPreviewView.setAlign(align);
    update();
}
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:7,代碼來源:AlignControl.java

示例14: getAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public Paint.Align getAlign() {
    return textMakingInfo.getAlign();
}
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:4,代碼來源:TextPreviewView.java

示例15: setAlign

import android.graphics.Paint; //導入方法依賴的package包/類
public void setAlign(Paint.Align align) {
    textMakingInfo.setAlign(align);
}
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:4,代碼來源:TextPreviewView.java


注:本文中的android.graphics.Paint.Align方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。