如何在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..
更多推荐
发布评论