当前位置: 首页>>代码示例>>Java>>正文


Java Typeface.BOLD属性代码示例

本文整理汇总了Java中android.graphics.Typeface.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.BOLD属性的具体用法?Java Typeface.BOLD怎么用?Java Typeface.BOLD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.graphics.Typeface的用法示例。


在下文中一共展示了Typeface.BOLD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateAdditionalHeadersView

/**
 * Set up the additional headers text view with the supplied header data.
 *
 * @param additionalHeaders List of header entries. Each entry consists of a header
 *                          name and a header value. Header names may appear multiple
 *                          times.
 *                          <p/>
 *                          This method is always called from within the UI thread by
 *                          {@link #showAdditionalHeaders()}.
 */
private void populateAdditionalHeadersView(final List<HeaderEntry> additionalHeaders) {
    SpannableStringBuilder sb = new SpannableStringBuilder();
    boolean first = true;
    for (HeaderEntry additionalHeader : additionalHeaders) {
        if (!first) {
            sb.append("\n");
        } else {
            first = false;
        }
        StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
        SpannableString label = new SpannableString(additionalHeader.label + ": ");
        label.setSpan(boldSpan, 0, label.length(), 0);
        sb.append(label);
        sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value));
    }
    mAdditionalHeadersView.setText(sb);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:27,代码来源:MessageHeader.java

示例2: applyCustomTypeFace

private static void applyCustomTypeFace(Paint paint, Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }

    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.setTypeface(tf);
}
 
开发者ID:ahmadnurhidayat,项目名称:Cook-It-Android-XML-Template,代码行数:20,代码来源:CustomTypefaceSpan.java

示例3: setFontWeight

/**
/* This code is duplicated in ReactTextInputManager
/* TODO: Factor into a common place they can both use
*/
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(@Nullable String fontWeightString) {
  int fontWeightNumeric = fontWeightString != null ?
      parseNumericFontWeight(fontWeightString) : -1;
  int fontWeight = UNSET;
  if (fontWeightNumeric >= 500 || "bold".equals(fontWeightString)) {
    fontWeight = Typeface.BOLD;
  } else if ("normal".equals(fontWeightString) ||
      (fontWeightNumeric != -1 && fontWeightNumeric < 500)) {
    fontWeight = Typeface.NORMAL;
  }
  if (fontWeight != mFontWeight) {
    mFontWeight = fontWeight;
    markUpdated();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:20,代码来源:ReactTextShadowNode.java

示例4: applyTypeface

public static void applyTypeface(Context context, Paint v) {
    if (v.getTypeface() == null) {
        v.setTypeface(getNormal(context));
        return;
    }
    switch (v.getTypeface().getStyle()) {
        case Typeface.BOLD:
            v.setTypeface(getNormal(context));
            v.setFakeBoldText(true);
            break;
        default:
            v.setTypeface(getNormal(context));
            break;
        case Typeface.ITALIC:
            v.setTypeface(getNormal(context));
            v.setTextSkewX(-0.25f);
            break;
        case Typeface.BOLD_ITALIC:
            v.setTypeface(getNormal(context));
            v.setFakeBoldText(true);
            v.setTextSkewX(-0.25f);
            break;
    }
}
 
开发者ID:iPanelkegy,项目名称:MobileMedia,代码行数:24,代码来源:Icon.java

示例5: setFontWeight

@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(@Nullable String fontWeightString) {
  final int fontWeight;
  if (fontWeightString == null) {
    fontWeight = -1;
  } else if (BOLD.equals(fontWeightString)) {
    fontWeight = Typeface.BOLD;
  } else if (NORMAL.equals(fontWeightString)) {
    fontWeight = Typeface.NORMAL;
  } else {
    int fontWeightNumeric = parseNumericFontWeight(fontWeightString);
    if (fontWeightNumeric == -1) {
      throw new RuntimeException("invalid font weight " + fontWeightString);
    }
    fontWeight = fontWeightNumeric >= 500 ? Typeface.BOLD : Typeface.NORMAL;
  }

  if (mFontStylingSpan.getFontWeight() != fontWeight) {
    getSpan().setFontWeight(fontWeight);
    notifyChanged(true);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:RCTVirtualText.java

示例6: checkGenericFont

private Typeface checkGenericFont(String fontName, Integer fontWeight,
		FontStyle fontStyle) {
	Typeface font = null;
	int typefaceStyle;

	boolean italic = (fontStyle == Style.FontStyle.Italic);
	typefaceStyle = (fontWeight > 500) ? (italic ? Typeface.BOLD_ITALIC
			: Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL);

	if (fontName.equals("serif")) {
		font = Typeface.create(Typeface.SERIF, typefaceStyle);
	} else if (fontName.equals("sans-serif")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("monospace")) {
		font = Typeface.create(Typeface.MONOSPACE, typefaceStyle);
	} else if (fontName.equals("cursive")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("fantasy")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	}
	return font;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:22,代码来源:SVGAndroidRenderer.java

示例7: apply

private void apply(final Paint paint, final Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }

    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.getShader();

    paint.setTypeface(tf);
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:22,代码来源:SpanUtils.java

示例8: applyCustomTypeFace

private void applyCustomTypeFace(Paint paint, Typeface tf) {
  int oldStyle;
  Typeface old = paint.getTypeface();
  if (old == null) {
    oldStyle = 0;
  } else {
    oldStyle = old.getStyle();
  }

  int fake = oldStyle & ~tf.getStyle();
  if ((fake & Typeface.BOLD) != 0) {
    paint.setFakeBoldText(true);
  }

  if ((fake & Typeface.ITALIC) != 0) {
    paint.setTextSkewX(-0.25f);
  }

  paint.setTypeface(tf);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:20,代码来源:EgenTypefaceSpan.java

示例9: getFontWeight

public static int getFontWeight(Map<String, Object> style) {
  int typeface = android.graphics.Typeface.NORMAL;
  if (style != null) {
    Object temp = style.get(Constants.Name.FONT_WEIGHT);
    if (temp != null) {
      String fontWeight = temp.toString();
      switch (fontWeight){
        case "600":
        case "700":
        case "800":
        case "900":
        case Constants.Value.BOLD:
          typeface=Typeface.BOLD;
          break;
      }
    }
  }
  return typeface;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:19,代码来源:WXStyle.java

示例10: setText

public void setText(Recipients recipients, boolean read) {
  int        attributes[] = new int[]{R.attr.conversation_list_item_count_color};
  TypedArray colors       = getContext().obtainStyledAttributes(attributes);
  String     fromString   = recipients.toShortString();

  int typeface;

  if (!read) {
    typeface = Typeface.BOLD;
  } else {
    typeface = Typeface.NORMAL;
  }

  SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
  builder.setSpan(new StyleSpan(typeface), 0, builder.length(),
                  Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

  colors.recycle();

  setText(builder);

  if      (recipients.isBlocked()) setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_grey600_18dp, 0, 0, 0);
  else if (recipients.isMuted())   setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_grey600_18dp, 0, 0, 0);
  else                             setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:25,代码来源:FromTextView.java

示例11: apply

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);
}
 
开发者ID:suragch,项目名称:mongol-library,代码行数:20,代码来源:MongolTypefaceSpan.java

示例12: applyFontStyle

public static void applyFontStyle(Paint paint, int style, int weight, String family) {
  int oldStyle;
  Typeface typeface = paint.getTypeface();
  if (typeface == null) {
    oldStyle = 0;
  } else {
    oldStyle = typeface.getStyle();
  }

  int want = 0;
  if ((weight == Typeface.BOLD)
    || ((oldStyle & Typeface.BOLD) != 0 && weight == WXStyle.UNSET)) {
    want |= Typeface.BOLD;
  }

  if ((style == Typeface.ITALIC)
    || ((oldStyle & Typeface.ITALIC) != 0 && style == WXStyle.UNSET)) {
    want |= Typeface.ITALIC;
  }

  if (family != null) {
    typeface = getOrCreateTypeface(family, want);
  }

  if (typeface != null) {
    paint.setTypeface(Typeface.create(typeface, want));
  } else {
    paint.setTypeface(Typeface.defaultFromStyle(want));
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:30,代码来源:TypefaceUtil.java

示例13: validateTypefaceStyle

private static void validateTypefaceStyle(int typefaceStyle) {
	switch (typefaceStyle) {
	case Typeface.NORMAL:
	case Typeface.BOLD:
	case Typeface.ITALIC:
	case Typeface.BOLD_ITALIC:
		break;
	default:
		throw new IllegalArgumentException("Invalid typeface style! Have to be one of " +
				"Typeface.NORMAL, Typeface.BOLD, Typeface.ITALIC or Typeface.BOLD_ITALIC");
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:TypefaceCollection.java

示例14: getFont

/**
 * Get the font based on the text style.
 *
 * @return font file name.
 */
String getFont(Typeface typeface) {
    switch (typeface != null ? typeface.getStyle() : Typeface.NORMAL) {
        case Typeface.BOLD_ITALIC:
            return String.format(Locale.US, "fonts/%s", "OpenSans-BoldItalic.ttf");
        case Typeface.ITALIC:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Italic.ttf");
        case Typeface.BOLD:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Bold.ttf");
        case Typeface.NORMAL:
        default:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Regular.ttf");
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:18,代码来源:BaseTextView.java

示例15: getName

public static String getName(int type) {
    switch (type) {
        case Typeface.ITALIC:
            return STYLE_ITALIC;
        case Typeface.BOLD:
            return STYLE_BOLD;
        default:
            return STYLE_NORMAL;
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:10,代码来源:UDFontStyle.java


注:本文中的android.graphics.Typeface.BOLD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。