Android 无衬线灯,带;“假粗体”;
我已为我的应用程序设置了以下主题:Android 无衬线灯,带;“假粗体”;,android,Android,我已为我的应用程序设置了以下主题: <style name="AppTheme" parent="Theme.Sherlock.Light"> <item name="android:textViewStyle">@style/RobotoTextViewStyle</item> </style> <style name="RobotoTextViewStyle" parent="android:Widget.TextView"&g
<style name="AppTheme" parent="Theme.Sherlock.Light">
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
</style>
<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>
这种字体源自roboto light,看起来非常不错
我想要这种粗体的浅色字体,但我想知道最优雅的方式是什么
BoldTextView扩展TextView
”,最好的实现是什么我最终为它创建了一个类:
public class FakeBoldTextView extends TextView {
public FakeBoldTextView(Context context) {
super(context);
setTypeface(getTypeface(), Typeface.BOLD);
}
public FakeBoldTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setTypeface(getTypeface(), Typeface.BOLD);
}
public FakeBoldTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setTypeface(getTypeface(), Typeface.BOLD);
}
}
在XML中使用它,如下所示:
<the.package.name.FakeBoldTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example string" />
棒棒糖支持
粗体
无衬线灯。
<the.package.name.FakeBoldTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example string" />