本文整理匯總了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;
}
示例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;
}
示例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;
}
示例4: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint tp) {
tp.setShadowLayer(radius, dx, dy, shadowColor);
}
示例5: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(final TextPaint tp) {
tp.setShadowLayer(radius, dx, dy, shadowColor);
}
示例6: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint tp) {
tp.setShadowLayer(radius, dx, dy, color);
}
示例7: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint textPaint) {
textPaint.setShadowLayer(mRadius, mDx, mDy, mColor);
}
示例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;
}