Android Can';t将自定义字体设置到按钮
我有一个按钮,像这样使用Android Can';t将自定义字体设置到按钮,android,material-design,Android,Material Design,我有一个按钮,像这样使用和按钮)。接下来我需要设置自定义字体,请参见下面的我的样式。在Studio designer面板中,自定义字体看起来不错,但在设备上运行的是Roboto(默认)字体,而不是我的自定义字体(Nunito)。有什么建议吗?AS4.1.2/API30 <style name="ButtonGetStarted" parent="Widget.MaterialComponents.Button"> <item na
和按钮)。接下来我需要设置自定义字体,请参见下面的我的样式。在Studio designer面板中,自定义字体看起来不错,但在设备上运行的是Roboto(默认)字体,而不是我的自定义字体(Nunito)。有什么建议吗?AS4.1.2/API30
<style name="ButtonGetStarted" parent="Widget.MaterialComponents.Button">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">60dp</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">24sp</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/text_invert</item>
<item name="android:fontFamily">@font/app_font</item>
<item name="android:background">@drawable/button_selector_get_started</item>
</style>
匹配父项
60dp
假的
24便士
大胆的
@颜色/文字翻转
@字体/应用程序字体
@可拖动/按钮选择器启动
app_font.xml:
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
<font
app:fontStyle="normal"
app:font="@font/nunito_regular" />
<font
app:fontStyle="italic"
app:font="@font/nunito_regular_italic" />
</font-family>
创建文本外观
这里举个例子
<style name="TextAppearance.Robin.Button" parent="TextAppearance.MaterialComponents.Button">
<item name="fontFamily">@font/dosis_medium</item>
<item name="android:fontFamily">@font/dosis_medium</item>
<item name="android:textSize">15sp</item>
</style>
@字体/剂量计介质
@字体/剂量计介质
15便士
现在设置按钮样式中的文本外观
<style name="ButtonGetStarted" parent="Widget.MaterialComponents.Button">
<item name="android:textAppearance">@style/TextAppearance.Robin.Button</item>
.
.
.
.
</style>
@style/TextAppearance.Robin.Button
.
.
.
.
也可以使用按钮本身
<Button
android:textAppearance:"android:textAppearance="@style/yourstYle
/>
很好的尝试,但这对我不起作用