如何在Style.xml中为Roboto资产创建样式(How to create style in style.xml for Roboto assets)

编程入门 行业动态 更新时间:2024-10-25 05:16:08
如何在Style.xml中为Roboto资产创建样式(How to create style in style.xml for Roboto assets)

我已将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>

但这不起作用

I have included the Roboto fonts in my project as assets. So now to define a TextView I can do

<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"/>

Now image I have a number of TextView that need to be style. Typically, I can simply define a style and reuse it. But I am not able to do that in the present situation because of app:typeface. How do Include that in my 'style.xml' file? I already tried

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

but that does not work

最满意答案

style.xml

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

(假设你使用的是android studio)

希望它能帮到你......

style.xml

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

(Assuming you are using android studio)

Hope it helps you..

更多推荐

本文发布于:2023-07-30 07:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336720.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中为   样式   资产   如何在   Style

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!