use of android.text.TextPaint in project DanmakuFlameMaster by Bilibili.
the class ViewCacheStuffer method measure.
@Override
public void measure(BaseDanmaku danmaku, TextPaint paint, boolean fromWorkerThread) {
int viewType = getItemViewType(danmaku.index, danmaku);
List<VH> viewHolders = mViewHolderArray.get(viewType);
if (viewHolders == null) {
viewHolders = new ArrayList<>();
viewHolders.add(onCreateViewHolder(viewType));
viewHolders.add(onCreateViewHolder(viewType));
viewHolders.add(onCreateViewHolder(viewType));
mViewHolderArray.put(viewType, viewHolders);
}
VH viewHolder = viewHolders.get(0);
// TODO displayerConfig or TextPaint
onBindViewHolder(viewType, viewHolder, danmaku, null, paint);
viewHolder.measure(View.MeasureSpec.makeMeasureSpec(mMaximumWidthPixels, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(mMaximumHeightPixels, View.MeasureSpec.AT_MOST));
viewHolder.layout(0, 0, viewHolder.getMeasureWidth(), viewHolder.getMeasureHeight());
danmaku.paintWidth = viewHolder.getMeasureWidth();
danmaku.paintHeight = viewHolder.getMeasureHeight();
}
use of android.text.TextPaint in project Android-Bootstrap by Bearded-Hen.
the class BootstrapDrawableFactory method createBadgeDrawable.
public static Drawable createBadgeDrawable(Context context, BootstrapBrand brand, int width, int height, String badgeText, boolean insideAnObject) {
if (badgeText == null) {
return null;
} else {
Paint badgePaint = new Paint();
Rect canvasBounds = new Rect();
TextPaint badgeTextPaint = new TextPaint();
badgePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
badgeTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
badgeTextPaint.setTextAlign(Paint.Align.CENTER);
badgeTextPaint.setTextSize((float) (height * 0.7));
if (insideAnObject) {
badgePaint.setColor(brand.defaultTextColor(context));
badgeTextPaint.setColor(brand.defaultFill(context));
} else {
badgePaint.setColor(brand.defaultFill(context));
badgeTextPaint.setColor(brand.defaultTextColor(context));
}
int rectLength = (int) badgeTextPaint.measureText(badgeText);
Bitmap canvasBitmap = Bitmap.createBitmap(width + rectLength, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(canvasBitmap);
canvas.getClipBounds(canvasBounds);
int firstCircleDx = canvasBounds.left + canvasBounds.height() / 2;
int circleDy = canvasBounds.height() / 2;
int circleRadius = canvasBounds.height() / 2;
int secondCircleDx = firstCircleDx + rectLength;
Rect rect = new Rect();
rect.left = firstCircleDx;
rect.top = 0;
rect.right = rect.left + rectLength;
rect.bottom = canvasBounds.height();
canvas.drawCircle(firstCircleDx, circleDy, circleRadius, badgePaint);
canvas.drawRect(rect, badgePaint);
canvas.drawCircle(secondCircleDx, circleDy, circleRadius, badgePaint);
canvas.drawText(badgeText, canvasBounds.width() / 2, canvasBounds.height() / 2 - ((badgeTextPaint.descent() + badgeTextPaint.ascent()) / 2), badgeTextPaint);
return new BitmapDrawable(context.getResources(), canvasBitmap);
}
}
use of android.text.TextPaint in project bilibili-android-client by HotBitmapGG.
the class RegionTypeDetailsActivity method measureTabLayoutTextWidth.
public void measureTabLayoutTextWidth(int position) {
String titleName = titles.get(position);
TextView titleView = mSlidingTab.getTitleView(position);
TextPaint paint = titleView.getPaint();
float v = paint.measureText(titleName);
mSlidingTab.setIndicatorWidth(v / 3);
}
use of android.text.TextPaint in project bilibili-android-client by HotBitmapGG.
the class VideoDetailsActivity method measureTabLayoutTextWidth.
private void measureTabLayoutTextWidth(int position) {
String title = titles.get(position);
TextView titleView = mSlidingTabLayout.getTitleView(position);
TextPaint paint = titleView.getPaint();
float textWidth = paint.measureText(title);
mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}
use of android.text.TextPaint in project bilibili-android-client by HotBitmapGG.
the class TotalStationSearchActivity method measureTabLayoutTextWidth.
private void measureTabLayoutTextWidth(int position) {
String title = titles.get(position);
TextView titleView = mSlidingTabLayout.getTitleView(position);
TextPaint paint = titleView.getPaint();
float textWidth = paint.measureText(title);
mSlidingTabLayout.setIndicatorWidth(textWidth / 3);
}
Aggregations