如何在Style.xml中为Roboto资源创建样式

时间:2015-11-30 06:17:18

标签: android android-layout styles

我已将Roboto字体作为资产包含在我的项目中。所以现在定义一个我可以做的TextView

<me.android.fonts.widget.RobotoTextView
        android:id="@+id/day"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:typeface="roboto_bold"
        android:textColor="@color/green_text"
        android:textSize="@dimen/day_size"
        tools:text="Tues"/>

现在我有一些需要样式的TextView。通常,我可以简单地定义一个样式并重用它。但由于app:typeface,我无法在目前的情况下这样做。如何在我的样式文件夹中包含它&#39;文件?我已经尝试了

<resources xmlns:app="http://schemas.android.com/apk/res-auto">
...
<style...>
...
</style>
</resources>

但这不起作用

1 个答案:

答案 0 :(得分:0)

<强> style.xml

<resources>
<style name="WidgetStyle.TextMedium">
    <item name="android:textSize">16sp</item>
    <item name="typeface">roboto_bold</item>
</style>
</resources>

(假设您使用的是android studio)

希望它可以帮助你..