【发布时间】:2020-09-27 14:00:13
【问题描述】:
我在我想要更改字体、颜色和字体大小的 Android 应用程序中使用 NumberPicker。
我环顾四周,在这里找到了这个解决方案:Setting typeFace to NumberPicker
所以我定义了我的风格如下:
<style name="NumberPickerText">
<item name="android:textSize">24sp</item>
<item name="android:textColorPrimary">@color/colorPrimary</item>
<item name="android:fontFamily">@font/poppins_light</item>
</style>
并将其应用于我的 NumberPicker,如下所示:
<NumberPicker
android:id="@+id/durationPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:theme="@style/NumberPickerText"/>
在 XML 设计窗口中查看我的活动时,它看起来就是我想要的样子。但是,当我在手机上运行该应用程序时,颜色和字体大小都按预期应用,但字体不是“Poppins”而是默认字体。
为什么我的字体在 XML 设计窗口中按预期显示,但在运行时显示不同?我怎样才能让字体如愿出现在运行时?
非常感谢您的帮助!
【问题讨论】:
标签: android typeface numberpicker