本文整理匯總了Java中android.text.TextPaint.setFakeBoldText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextPaint.setFakeBoldText方法的具體用法?Java TextPaint.setFakeBoldText怎麽用?Java TextPaint.setFakeBoldText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.text.TextPaint
的用法示例。
在下文中一共展示了TextPaint.setFakeBoldText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addTab
import android.text.TextPaint; //導入方法依賴的package包/類
/**
* 添加指示器
*
* @param position
* @param title
*/
private void addTab(final int position, CharSequence title) {
TextView tvTab = new TextView(context);
tvTab.setText(title);
tvTab.setTextColor(textColor);
tvTab.setTextSize(textSize);
tvTab.setGravity(Gravity.CENTER);
if(isIndicatorTextBold){
TextPaint tp = tvTab.getPaint();
tp.setFakeBoldText(true);
}
tvTab.setSingleLine();
tvTab.setFocusable(true);
tvTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
viewPager.setCurrentItem(position);
}
});
tvTab.setPadding(indicatorMargin, 0, indicatorMargin, 0);
container.addView(tvTab, position, expandedTabLayoutParams);
}
示例2: apply
import android.text.TextPaint; //導入方法依賴的package包/類
private void apply(TextPaint paint) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
final int fakeStyle = oldStyle & ~typeface.getStyle();
if ((fakeStyle & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fakeStyle & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(typeface);
}
示例3: RoundedIconGenerator
import android.text.TextPaint; //導入方法依賴的package包/類
/**
* Constructs the generator and initializes the common members ignoring display density.
*
* @param iconWidthPx The width of the generated icon in pixels.
* @param iconHeightPx The height of the generated icon in pixels.
* @param cornerRadiusPx The radius of the corners in the icon in pixels.
* @param backgroundColor Color at which the rounded rectangle should be drawn.
* @param textSizePx Size at which the text should be drawn in pixels.
*/
public RoundedIconGenerator(int iconWidthPx, int iconHeightPx, int cornerRadiusPx,
int backgroundColor, float textSizePx) {
mIconWidthPx = iconWidthPx;
mIconHeightPx = iconHeightPx;
mCornerRadiusPx = cornerRadiusPx;
mBackgroundRect = new RectF(0, 0, mIconWidthPx, mIconHeightPx);
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBackgroundPaint.setColor(backgroundColor);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setColor(Color.WHITE);
mTextPaint.setFakeBoldText(true);
mTextPaint.setTextSize(textSizePx);
FontMetrics textFontMetrics = mTextPaint.getFontMetrics();
mTextHeight = (float) Math.ceil(textFontMetrics.bottom - textFontMetrics.top);
mTextYOffset = -textFontMetrics.top;
}
示例4: build
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public Builder build() {
//Set the keyboard paint
mKeyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mKeyPaint.setStyle(Paint.Style.STROKE);
mKeyPaint.setColor(mKeyStrokeColor);
mKeyPaint.setTextSize(mKeyTextSize);
mKeyPaint.setStrokeWidth(mKeyStrokeWidth);
//Set the keyboard text paint
mKeyTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mKeyTextPaint.setColor(mKeyTextColor);
mKeyTextPaint.setTextSize(mKeyTextSize);
mKeyTextPaint.setFakeBoldText(true);
mKeyTextPaint.setTextAlign(Paint.Align.CENTER);
//Ripple paint
mClickPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mClickPaint.setStyle(Paint.Style.STROKE);
mClickPaint.setColor(Utils.makeColorDark(mKeyStrokeColor));
mClickPaint.setStrokeWidth(mKeyStrokeWidth);
return this;
}
示例5: build
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public Builder build() {
//Set the keyboard paint
mKeyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mKeyPaint.setStyle(Paint.Style.STROKE);
mKeyPaint.setColor(mKeyStrokeColor);
mKeyPaint.setTextSize(mKeyTextSize);
mKeyPaint.setStrokeWidth(mKeyStrokeWidth);
//Set the keyboard text paint
mKeyTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mKeyTextPaint.setColor(mKeyTextColor);
mKeyTextPaint.setTextSize(mKeyTextSize);
mKeyTextPaint.setFakeBoldText(true);
mKeyTextPaint.setTextAlign(Paint.Align.CENTER);
return this;
}
示例6: getView
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.local_audio_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.thumbnail = (ImageView) convertView.
findViewById(R.id.iv_local_video_thumbnail);
viewHolder.displayName = (TextView) convertView.
findViewById(R.id.tv_local_video_display_name);
viewHolder.duration = (TextView) convertView.
findViewById(R.id.tv_local_video_duration);
viewHolder.size = (TextView) convertView.
findViewById(R.id.tv_local_video_size);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
MediaItem mediaItem = (MediaItem) getItem(position);
viewHolder.displayName.setText(mediaItem.getDisplayName());
TextPaint paint = viewHolder.displayName.getPaint();
paint.setFakeBoldText(true);
viewHolder.duration.setText(TimeUtils.toTimeStr(mediaItem.getDuration()));
viewHolder.size.setText(SizeUtils.toSizeStr(mediaItem.getSize()));
return convertView;
}
示例7: TitleBitmapFactory
import android.text.TextPaint; //導入方法依賴的package包/類
/**
* @param context The current Android's context.
* @param incognito Whether the title are for incognito mode.
* @param nullFaviconResourceId A drawable resource id of a default favicon.
*/
public TitleBitmapFactory(Context context, boolean incognito, int nullFaviconResourceId) {
mNullFaviconResourceId = nullFaviconResourceId;
Resources res = context.getResources();
int textColor = ApiCompatibilityUtils.getColor(res, incognito
? R.color.compositor_tab_title_bar_text_incognito
: R.color.compositor_tab_title_bar_text);
float textSize = res.getDimension(R.dimen.compositor_tab_title_text_size);
boolean fakeBoldText = res.getBoolean(R.bool.compositor_tab_title_fake_bold_text);
mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setColor(textColor);
mTextPaint.setTextSize(textSize);
mTextPaint.setFakeBoldText(fakeBoldText);
mTextPaint.density = res.getDisplayMetrics().density;
FontMetrics textFontMetrics = mTextPaint.getFontMetrics();
mTextHeight = (float) Math.ceil(textFontMetrics.bottom - textFontMetrics.top);
mTextYOffset = -textFontMetrics.top;
mFaviconDimension = res.getDimensionPixelSize(R.dimen.compositor_tab_title_favicon_size);
mViewHeight = (int) Math.max(mFaviconDimension, mTextHeight);
int width = res.getDisplayMetrics().widthPixels;
int height = res.getDisplayMetrics().heightPixels;
mMaxWidth = (int) (TITLE_WIDTH_PERCENTAGE * Math.max(width, height));
// Set the favicon dimension here.
mFaviconDimension = Math.min(mMaxWidth, mFaviconDimension);
}
示例8: getView
import android.text.TextPaint; //導入方法依賴的package包/類
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
boolean z = true;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(this.mContext).inflate(R.layout.garbage_file_item, null);
ViewHolder.access$002(holder, (TextView) convertView.findViewById(R.id.tv_garbage_file_item_type));
ViewHolder.access$102(holder, (TextView) convertView.findViewById(R.id.tv_garbage_file_item_size));
ViewHolder.access$202(holder, (ImageView) convertView.findViewById(R.id.iv_garbage_file_selection));
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (!(this.mList == null || this.mList.get(position) == null)) {
boolean z2;
ViewHolder.access$000(holder).setText(getNameByType(((GarbageFileInfo) this.mList.get(position)).type));
TextPaint tp = ViewHolder.access$000(holder).getPaint();
if (position == 0) {
z2 = true;
} else {
z2 = false;
}
tp.setFakeBoldText(z2);
tp = ViewHolder.access$100(holder).getPaint();
if (position != 0) {
z = false;
}
tp.setFakeBoldText(z);
StringBuilder sb = new StringBuilder();
sb.append(GarbageCleanActivity.transformShortType(((GarbageFileInfo) this.mList.get(position)).size));
sb.append(GarbageCleanActivity.transformUnit(((GarbageFileInfo) this.mList.get(position)).size));
ViewHolder.access$100(holder).setText(sb.toString());
}
if (this.mGarbageFileTypeSelectionList.contains(((GarbageFileInfo) this.mList.get(position)).type)) {
ViewHolder.access$200(holder).setVisibility(0);
} else {
ViewHolder.access$200(holder).setVisibility(4);
}
return convertView;
}
示例9: updateDrawState
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public void updateDrawState(TextPaint ds) {
//log("TagSpan:updateDrawState:" + isPreDeleteState);
ds.setFakeBoldText(true);
if (willRemove) {
ds.setColor(0xFFFFFFFF);
ds.bgColor = 0xFF24cf5f;
} else {
super.updateDrawState(ds);
}
}
示例10: setSwitchTypeface
import android.text.TextPaint; //導入方法依賴的package包/類
public void setSwitchTypeface(Typeface tf, int style) {
boolean z = false;
if (style > 0) {
int typefaceStyle;
float f;
if (tf == null) {
tf = Typeface.defaultFromStyle(style);
} else {
tf = Typeface.create(tf, style);
}
setSwitchTypeface(tf);
if (tf != null) {
typefaceStyle = tf.getStyle();
} else {
typefaceStyle = 0;
}
int need = style & (typefaceStyle ^ -1);
TextPaint textPaint = this.mTextPaint;
if ((need & 1) != 0) {
z = true;
}
textPaint.setFakeBoldText(z);
textPaint = this.mTextPaint;
if ((need & 2) != 0) {
f = -0.25f;
} else {
f = 0.0f;
}
textPaint.setTextSkewX(f);
return;
}
this.mTextPaint.setFakeBoldText(false);
this.mTextPaint.setTextSkewX(0.0f);
setSwitchTypeface(tf);
}
示例11: setTopTitleBold
import android.text.TextPaint; //導入方法依賴的package包/類
protected void setTopTitleBold(String title) {
if (title == null) {
return;
}
if (title.length() > 12) {
title = title.substring(0, 11) + "...";
}
// 設置字體為加粗
TextPaint paint = topTitleTxt.getPaint();
paint.setFakeBoldText(true);
topTitleTxt.setText(title);
topTitleTxt.setVisibility(View.VISIBLE);
}
示例12: init
import android.text.TextPaint; //導入方法依賴的package包/類
private void init() {
setContentView(R.layout.dialog_alert);
this.mTitleView = (TextView) findViewById(R.id.title);
final TextPaint tp = this.mTitleView.getPaint();
tp.setFakeBoldText(true);
this.mTitleView.setText(this.mTitle);
this.mTextView = (TextView) findViewById(R.id.text);
this.mTextView.setText(this.mText);
this.mButtonOk = (Button) findViewById(R.id.button_ok);
this.mButtonOk.setOnClickListener(this);
}
示例13: getView
import android.text.TextPaint; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.local_video_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.thumbnail = (ImageView) convertView.
findViewById(R.id.iv_local_video_thumbnail);
viewHolder.displayName = (TextView) convertView.
findViewById(R.id.tv_local_video_display_name);
viewHolder.duration = (TextView) convertView.
findViewById(R.id.tv_local_video_duration);
viewHolder.size = (TextView) convertView.
findViewById(R.id.tv_local_video_size);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
MediaItem mediaItem = (MediaItem) getItem(position);
ImageLoader.bindVideoThumbnailWithPath(mediaItem.getPath(), viewHolder.thumbnail);
viewHolder.displayName.setText(mediaItem.getDisplayName());
viewHolder.displayName.setText(mediaItem.getDisplayName());
TextPaint paint = viewHolder.displayName.getPaint();
paint.setFakeBoldText(true);
viewHolder.duration.setText(TimeUtils.toTimeStr(mediaItem.getDuration()));
viewHolder.size.setText(SizeUtils.toSizeStr(mediaItem.getSize()));
return convertView;
}
示例14: setBold
import android.text.TextPaint; //導入方法依賴的package包/類
public static void setBold(TextView textView) {
if (textView != null) {
TextPaint paint = textView.getPaint();
paint.setFakeBoldText(true);
}
}
示例15: setFakeBold
import android.text.TextPaint; //導入方法依賴的package包/類
public static void setFakeBold(TextView textView, boolean isBold)
{
TextPaint tp = textView.getPaint();
tp.setFakeBoldText(isBold);
}