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


Java TextPaint.setShadowLayer方法代碼示例

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


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

示例1: getOverlayBitmap2

import android.text.TextPaint; //導入方法依賴的package包/類
public static Bitmap getOverlayBitmap2(Context context, Bitmap bitmap, String text) {
    Bitmap result = bitmap.copy(bitmap.getConfig(), true);
    float scale = context.getResources().getDisplayMetrics().density;
    Canvas canvas = new Canvas(result);

    TextPaint mTextPaint = new TextPaint();
    mTextPaint.setTextSize((int) (12 * scale));
    mTextPaint.setColor(Color.WHITE);
    mTextPaint.setAlpha(204);
    mTextPaint.setShadowLayer(5f, 0f, 1f, Color.DKGRAY);

    StaticLayout mTextLayout = new StaticLayout(text, mTextPaint, canvas.getWidth() - Util.dpToPx(87), Layout.Alignment.ALIGN_CENTER, 1.0f, 0.3f, true);
    canvas.save();

    float textX = (canvas.getWidth() / 2) - (mTextLayout.getWidth() / 2);
    float textY = result.getHeight() - Util.dpToPx(72);

    canvas.translate(textX, textY);
    mTextLayout.draw(canvas);
    canvas.restore();
    return result;
}
 
開發者ID:SinsangMarket,項目名稱:ASS,代碼行數:23,代碼來源:Util.java

示例2: getPaint

import android.text.TextPaint; //導入方法依賴的package包/類
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean quick) {
    TextPaint paint;
    if (quick) {
        paint = this.PAINT_DUPLICATE;
        paint.set(this.PAINT);
    } else {
        paint = this.PAINT;
    }
    paint.reset();
    paint.setTextSize(danmaku.textSize);
    applyTextScaleConfig(danmaku, paint);
    if (!this.HAS_SHADOW || this.SHADOW_RADIUS <= 0.0f || danmaku.textShadowColor == 0) {
        paint.clearShadowLayer();
    } else {
        paint.setShadowLayer(this.SHADOW_RADIUS, 0.0f, 0.0f, danmaku.textShadowColor);
    }
    paint.setAntiAlias(this.ANTI_ALIAS);
    return paint;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:AndroidDisplayer.java

示例3: getPaint

import android.text.TextPaint; //導入方法依賴的package包/類
private synchronized TextPaint getPaint(BaseDanmaku danmaku, boolean fromWorkerThread) {
    TextPaint paint;
    if (fromWorkerThread) {
        paint = PAINT;
    } else {
        paint = PAINT_DUPLICATE;
        paint.set(PAINT);
    }
    paint.setTextSize(danmaku.textSize);
    applyTextScaleConfig(danmaku, paint);

    //ignore the transparent textShadowColor
    if (!HAS_SHADOW || SHADOW_RADIUS <= 0 || danmaku.textShadowColor == 0) {
        paint.clearShadowLayer();
    } else {
        paint.setShadowLayer(SHADOW_RADIUS, 0, 0, danmaku.textShadowColor);
    }
    paint.setAntiAlias(ANTI_ALIAS);
    return paint;
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:21,代碼來源:AndroidDisplayer.java

示例4: updateDrawState

import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint tp) {
    tp.setShadowLayer(radius, dx, dy, shadowColor);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:ShadowSpan.java

示例5: updateDrawState

import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(final TextPaint tp) {
    tp.setShadowLayer(radius, dx, dy, shadowColor);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:SpanUtils.java

示例6: updateDrawState

import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint tp) {
    tp.setShadowLayer(radius, dx, dy, color);
}
 
開發者ID:geansea,項目名稱:GSLayout,代碼行數:5,代碼來源:GSShadowSpan.java

示例7: updateDrawState

import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint textPaint) {
  textPaint.setShadowLayer(mRadius, mDx, mDy, mColor);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:5,代碼來源:ShadowStyleSpan.java

示例8: drawMultilineTextToBitmap

import android.text.TextPaint; //導入方法依賴的package包/類
public Bitmap drawMultilineTextToBitmap(Bitmap bitmap, String gText) {
    int scale = 1;
    android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
    // set default bitmap config if none
    if (bitmapConfig == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
    }
    // resource bitmaps are imutable,
    // so we need to convert it to mutable one
    bitmap = bitmap.copy(bitmapConfig, true);

    Canvas canvas = new Canvas(bitmap);

    // new antialiased Paint
    TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    // text color - #3D3D3D
    paint.setColor(Color.rgb(61, 61, 61));
    // text size in pixels
    paint.setTextSize(14 * scale);
    // text shadow
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    // set text width to canvas width minus 16dp padding
    int textWidth = canvas.getWidth() - 16 * scale;

    // init StaticLayout for text
    StaticLayout textLayout = new StaticLayout(
            gText, paint, textWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);

    // get height of multiline text
    int textHeight = textLayout.getHeight();

    // get position of text's top left corner
    float x = (bitmap.getWidth() - textWidth) / 2;
    float y = (bitmap.getHeight() - textHeight) / 2;

    // draw text to the Canvas center
    canvas.save();
    canvas.translate(x, y);
    textLayout.draw(canvas);
    canvas.restore();

    return bitmap;
}
 
開發者ID:alepacheco,項目名稱:AndroRW,代碼行數:45,代碼來源:MyService.java


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