Java Code Examples for android.text.TextPaint.setFakeBoldText()

The following are Jave code examples for showing how to use setFakeBoldText() of the android.text.TextPaint class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: NeuTV   File: TabStrip.java   Source Code and License Vote up 6 votes
/**
 * 添加指示器
 *
 * @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);
}
 
Example 2
Project: mongol-library   File: MongolTypefaceSpan.java   Source Code and License Vote up 6 votes
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);
}
 
Example 3
Project: chromium-for-android-56-debug-video   File: RoundedIconGenerator.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 4
Project: PasscodeView   File: SquareKey.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 5
Project: PasscodeView   File: RoundKey.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 6
Project: PasscodeView   File: RectKey.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 7
Project: MobileMedia   File: LocalAudioAdapter.java   Source Code and License Vote up 6 votes
@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;
}
 
Example 8
Project: chromium-for-android-56-debug-video   File: TitleBitmapFactory.java   Source Code and License Vote up 5 votes
/**
 * @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);
}
 
Example 9
Project: letv   File: GarbageFileListAdapter.java   Source Code and License Vote up 5 votes
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;
}
 
Example 10
Project: OSchina_resources_android   File: RichEditText.java   Source Code and License Vote up 5 votes
@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);
    }
}
 
Example 11
Project: boohee_v5.6   File: SwitchCompat.java   Source Code and License Vote up 5 votes
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);
}
 
Example 12
Project: sctalk   File: TTBaseFragment.java   Source Code and License Vote up 5 votes
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);
			
}
 
Example 13
Project: mesh-core-on-android   File: AlertInfoDialog.java   Source Code and License Vote up 5 votes
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);

}
 
Example 14
Project: MobileMedia   File: LocalVideoAdapter.java   Source Code and License Vote up 5 votes
@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;
}
 
Example 15
Project: HtmlNative   File: StyleHelper.java   Source Code and License Vote up 4 votes
public static void setBold(TextView textView) {
    if (textView != null) {
        TextPaint paint = textView.getPaint();
        paint.setFakeBoldText(true);
    }
}
 
Example 16
Project: amap   File: MIP_TextStyle.java   Source Code and License Vote up 4 votes
public static void setFakeBold(TextView textView, boolean isBold)
{
    TextPaint tp = textView.getPaint();
    tp.setFakeBoldText(isBold);
}
 
Example 17
Project: Markwon   File: StrongEmphasisSpan.java   Source Code and License Vote up 4 votes
@Override
public void updateMeasureState(TextPaint p) {
    p.setFakeBoldText(true);
}
 
Example 18
Project: Markwon   File: StrongEmphasisSpan.java   Source Code and License Vote up 4 votes
@Override
public void updateDrawState(TextPaint tp) {
    tp.setFakeBoldText(true);
}
 
Example 19
Project: GoMeet   File: MapsMarkerActivity.java   Source Code and License Vote up 4 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Retrieve the content view that renders the map.
        setContentView(R.layout.activity_maps);
        // Add title
        getSupportActionBar().setTitle("Event Details");
        // Add Back button
        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
        if(actionBar != null){
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        // Get intent
        Intent intename = getIntent();
//        nameString = (String) intename.getSerializableExtra("NAME");
//        timeString = (String) intename.getSerializableExtra("TIME");
        nameString = "lalala";
        timeString = "24:00";
        descriptionString = (String) intename.getSerializableExtra("PostText");
        lat = (double) intename.getSerializableExtra("LAT");
        lng = (double) intename.getSerializableExtra("LNG");
//        zipcodeString = (String) intename.getSerializableExtra("ZIPCODE");
//        addressString = (String) intename.getSerializableExtra("ADDRESS");
        zipcodeString = "02215";
        addressString = "PHO";
        location = new LatLng(lat, lng);
        // Get the SupportMapFragment and request notification
        // when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
        // Get TextView
        name = (TextView) findViewById(R.id.Name);
        time = (TextView) findViewById(R.id.Time);
        description = (TextView) findViewById(R.id.Description);
        // Get Button
        mapAppCtrl = (Button) findViewById(R.id.openMap);
        mapAppCtrl.setOnClickListener(new MapsMarkerActivity.ButtonClickHandler());
        // Set TextView uneditable
        name.setKeyListener(null);
        time.setKeyListener(null);
        description.setKeyListener(null);
        // Set TextView size and bold
        name.setTextSize(20);
        time.setTextSize(10);
        TextPaint paint = name.getPaint();
        paint.setFakeBoldText(true);
        //Set content
        name.setText(nameString);
        time.setText(timeString);
        description.setText(String.format("%s\n%s\n%s", descriptionString, addressString, zipcodeString));
    }