【发布时间】:2019-07-09 12:34:15
【问题描述】:
我正在创建一个类并设置文本样式。我已经在 attrs 和 styleable 和 style 中定义了 getter setter 和 set textStyle bold 仍然文本没有变粗。如何设置粗体字?请帮忙?
<declare-styleable name="CustomTagGroup">
<attr name="descriptionTextStyle" format="flags">
<flag name="normal" value="0" />
<flag name="bold" value="1" />
<flag name="italic" value="2" />
<flag name="bolditalic" value="3" />
</attr>
<style name="CustomTagGroup">
<item name="atg_horizontalPadding">12dp</item>
<item name="atg_verticalPadding">3dp</item>
<item name="android:textStyle">bold</item>
<item name="descriptionTextStyle">bolditalic</item>
</style>
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTagGroup, defStyleAttr, R.style.CustomTagGroup);
try {
a.getType(R.styleable.CustomTagGroup_descriptionTextStyle);
int bold = Typeface.BOLD_ITALIC;
textStyle = a.getInt(R.styleable.CustomTagGroup_descriptionTextStyle, bold);
}catch(Exception e){
e.printStackTrace()
}
【问题讨论】: