/**
* @param position The difference between the distance mCurrentSelected.
* @param type The difference from mCurrentSelected 1 means downward drawing, and -1 indicates upward rendering.
*/
private void drawOtherText(Canvas canvas, int position, int type) {
float d = MARGIN_ALPHA * mMinTextSize * position + type * mMoveLen;
float scale = parabola(mViewHeight / 4.0f, d);
float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
nPaint.setTextSize(size);
nPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
float y = (float) (mViewHeight / 2.0 + type * d);
FontMetricsInt fmi = nPaint.getFontMetricsInt();
float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
canvas.drawText(mDataList.get(mCurrentSelected + type * position),
(float) (mViewWidth / 2.0), baseline, nPaint);
}
java类android.graphics.Paint.FontMetricsInt的实例源码
DatePickerView.java 文件源码
项目:androidtools
阅读 34
收藏 0
点赞 0
评论 0
EmojiSpan.java 文件源码
项目:PeSanKita-android
阅读 23
收藏 0
点赞 0
评论 0
@Override public int getSize(Paint paint, CharSequence text, int start, int end,
FontMetricsInt fm)
{
if (fm != null && this.fm != null) {
fm.ascent = this.fm.ascent;
fm.descent = this.fm.descent;
fm.top = this.fm.top;
fm.bottom = this.fm.bottom;
return size;
} else {
return super.getSize(paint, text, start, end, fm);
}
}
PickerView.java 文件源码
项目:YiZhi
阅读 23
收藏 0
点赞 0
评论 0
/**
* @param canvas
* @param position 距离mCurrentSelected的差值
* @param type 1表示向下绘制,-1表示向上绘制
*/
private void drawOtherText(Canvas canvas, int position, int type) {
float d = (float) (MARGIN_ALPHA * mMinTextSize * position + type
* mMoveLen);
float scale = parabola(mViewHeight / 4.0f, d);
float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
mPaint.setTextSize(size);
mPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
float y = (float) (mViewHeight / 2.0 + type * d);
FontMetricsInt fmi = mPaint.getFontMetricsInt();
float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));
canvas.drawText(mDataList.get(mCurrentSelected + type * position),
(float) (mViewWidth / 2.0), baseline, mPaint);
}
EmojiSpan.java 文件源码
项目:Nird2
阅读 25
收藏 0
点赞 0
评论 0
@Override
public int getSize(Paint paint, CharSequence text, int start, int end,
FontMetricsInt fm) {
if (fm != null && this.fm != null) {
fm.ascent = this.fm.ascent;
fm.descent = this.fm.descent;
fm.top = this.fm.top;
fm.bottom = this.fm.bottom;
return size;
} else {
return super.getSize(paint, text, start, end, fm);
}
}
EmojiSpan.java 文件源码
项目:Nird2
阅读 26
收藏 0
点赞 0
评论 0
@Override
public int getSize(Paint paint, CharSequence text, int start, int end,
FontMetricsInt fm) {
if (fm != null && this.fm != null) {
fm.ascent = this.fm.ascent;
fm.descent = this.fm.descent;
fm.top = this.fm.top;
fm.bottom = this.fm.bottom;
return size;
} else {
return super.getSize(paint, text, start, end, fm);
}
}
VideoShotEditActivity.java 文件源码
项目:letv
阅读 49
收藏 0
点赞 0
评论 0
private String getFileAddedWatermark(String path, String text, String voice) {
if (!new File(path).exists()) {
return null;
}
Options options = new Options();
options.inJustDecodeBounds = false;
Bitmap bitmap0 = BitmapFactory.decodeFile(path, options);
int width = options.outWidth;
int height = options.outHeight;
Bitmap bitmapPic = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapPic);
canvas.drawBitmap(bitmap0, null, new Rect(0, 0, width, height), null);
Paint textPaint = new Paint();
textPaint.setColor(-1);
textPaint.setTextSize((float) getTextSize());
textPaint.setFlags(2);
canvas.drawText(text, 0, text.length(), 30.0f, 50.0f, textPaint);
Rect rect = new Rect(0, height - getTextBgHeight(), width, height);
if (!isOrigPicMode) {
Paint voiceBgPaint = new Paint();
voiceBgPaint.setColor(getResources().getColor(2131493164));
voiceBgPaint.setStyle(Style.FILL);
voiceBgPaint.setFlags(2);
canvas.drawRect(rect, voiceBgPaint);
voiceBgPaint.setColor(-1);
voiceBgPaint.setTextSize((float) getTextSize());
voiceBgPaint.setTextAlign(Align.CENTER);
FontMetricsInt fontMetrics = voiceBgPaint.getFontMetricsInt();
int baseline = (rect.top + ((((rect.bottom - rect.top) - fontMetrics.bottom) + fontMetrics.top) / 2)) - fontMetrics.top;
canvas.drawText(voice, (float) rect.centerX(), (float) baseline, voiceBgPaint);
}
return saveBitmap(bitmapPic);
}
VideoShotEditActivity.java 文件源码
项目:letv
阅读 29
收藏 0
点赞 0
评论 0
private boolean saveFileAddedVoice(String path, String voice, String savePath) {
LogInfo.log("fornia", "voice:" + voice);
if (!new File(path).exists()) {
return false;
}
Options options = new Options();
options.inJustDecodeBounds = false;
Bitmap bitmap0 = BitmapFactory.decodeFile(path, options);
int width = options.outWidth;
int height = options.outHeight;
Bitmap bitmapPic = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapPic);
canvas.drawBitmap(bitmap0, null, new Rect(0, 0, width, height), null);
Rect targetBgRect = new Rect(0, height - getTextBgHeight(), width, height);
if (!isOrigPicMode) {
Paint voiceBgPaint = new Paint();
voiceBgPaint.setColor(getResources().getColor(2131493164));
voiceBgPaint.setStyle(Style.FILL);
voiceBgPaint.setFlags(2);
canvas.drawRect(targetBgRect, voiceBgPaint);
voiceBgPaint.setColor(-1);
voiceBgPaint.setTextSize((float) getTextSize());
voiceBgPaint.setTextAlign(Align.CENTER);
FontMetricsInt fontMetrics = voiceBgPaint.getFontMetricsInt();
String str = voice;
canvas.drawText(str, (float) targetBgRect.centerX(), (float) ((targetBgRect.top + ((((targetBgRect.bottom - targetBgRect.top) - fontMetrics.bottom) + fontMetrics.top) / 2)) - fontMetrics.top), voiceBgPaint);
}
return FileUtils.saveBitmapByUser(this.mContext, bitmapPic);
}
LabelSpan.java 文件源码
项目:mvvm-template
阅读 22
收藏 0
点赞 0
评论 0
@Override public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) {
setupFontMetrics(text, start, end, fm, paint);
if (fm != null) {
final int padding = dims.getPadding();
final int margin = dims.getMarginTop();
fm.ascent = Math.min(fm.top, fm.ascent - padding) - margin;
fm.descent = Math.max(fm.bottom, padding);
fm.top = fm.ascent;
fm.bottom = fm.descent;
}
return measureWidth(txtPaint, text, start, end, dims.isRtl());
}
LabelSpan.java 文件源码
项目:mvvm-template
阅读 27
收藏 0
点赞 0
评论 0
private void setupFontMetrics(CharSequence text, int start, int end, FontMetricsInt fm, Paint p) {
txtPaint.set(p);
final CharacterStyle[] otherSpans = ((Spanned) text).getSpans(start, end, CharacterStyle.class);
for (CharacterStyle otherSpan : otherSpans) {
otherSpan.updateDrawState(txtPaint);
}
txtPaint.setTextSize(p.getTextSize());
if (fm != null) {
txtPaint.getFontMetricsInt(fm);
}
}
TextLineImpl15.java 文件源码
项目:FastTextView
阅读 34
收藏 0
点赞 0
评论 0
/**
* @param wp
*/
private static void expandMetricsFromPaint(FontMetricsInt fmi, TextPaint wp) {
final int previousTop = fmi.top;
final int previousAscent = fmi.ascent;
final int previousDescent = fmi.descent;
final int previousBottom = fmi.bottom;
final int previousLeading = fmi.leading;
wp.getFontMetricsInt(fmi);
updateMetrics(fmi, previousTop, previousAscent, previousDescent, previousBottom,
previousLeading);
}