【问题标题】:How to create style in style.xml for Roboto assets如何在 style.xml 中为 Roboto 资产创建样式
【发布时间】:2015-11-30 06:17:18
【问题描述】:

我已将 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,在目前的情况下我无法做到这一点。如何将其包含在我的“style.xml”文件中?我已经试过了

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

但这不起作用

【问题讨论】:

    标签: android android-layout styles


    【解决方案1】:

    style.xml

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

    (假设你使用的是android studio)

    希望对你有帮助..

    【讨论】:

      猜你喜欢
      • 2011-05-23
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 2013-05-12
      • 2019-05-18
      • 1970-01-01
      相关资源
      最近更新 更多