Android DatePicker 字体
我知道您可以将自定义 TypeFace 应用于 Android 中的 TextView,如下所示:
TextView tv = findViewById(R.id.textview01);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/BLACKROSE.TTF");
tv.setTypeface(tf);
Is there any way possible to do this for a DatePicker?
I am aware you can apply a custom TypeFace to a TextView in Android like this:
TextView tv = findViewById(R.id.textview01);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/BLACKROSE.TTF");
tv.setTypeface(tf);
Is there any way possible to do this for a DatePicker?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是我的代码。我希望它对某人有用。
...
Here is my code. I hope it will be useful to someone.
...
查看源代码后,Datepicker 小部件包含 3 个 NumberPicker 小部件(分别代表日、月、年),而这些小部件又包含一个 TextView。因此,您必须在 DatePicker 内的 NumberPickers 内设置 TextView 的字体。
我认为您必须获取 NumberPicker 和 DatePicker 的源代码并修改源代码才能实现此目的,恐怕说起来容易做起来难。
After taking a look at the source, the Datepicker widget holds 3 NumberPicker widgets (for day, month, year)which in turn hold a TextView. So you are going have to set the Typeface for the TextView inside the NumberPickers inside the DatePicker.
I think you'll have to get the source for both NumberPicker and DatePicker and modify the source to achieve this, easier said than done I'm afraid.
这是我的解决方案:
Here is my solution:
如果您可以使用 DatePickerDialog,那么您可以简单地获取对话框的按钮,例如:
If you can use DatePickerDialog, then u can simply get the buttons of the dialog, like:
Kotlin-Anko 相当于 SKG 的解决方案
Kotlin-Anko equivalent to SKG's solution