更改 CalendarView Android 中的字体系列

问题描述 投票:0回答:1

有没有办法在 Android Studio 的标准 CalendarView 中更改字体系列? 我尝试制作一种样式,但它仅适用于构建后的字体颜色。在预览窗口中,日历会显示我的字体系列。

预览图

构建镜像后

这是我的风格:

    <style name="CalendarDataTextStyle" parent="android:TextAppearance.DeviceDefault">
        <item name="android:textColor">@color/colorBackOne</item>
        <item name="android:fontFamily">@font/sen_bold</item>
    </style>

    <style name="CalendarWeeksTextStyle" parent="android:TextAppearance.DeviceDefault">
        <item name="android:textColor">@color/colorGrey</item>
        <item name="android:fontFamily">@font/sen_bold</item>
    </style>

这是我的日历视图:

    <CalendarView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/calendar_back"
        android:layout_marginTop="30sp"

        android:dateTextAppearance="@style/CalendarDataTextStyle"
        android:weekDayTextAppearance="@style/CalendarWeeksTextStyle"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
java android android-layout calendarview
1个回答
0
投票

我认为您可以做一些事情:

  1. 创建自定义 CalendarView 组件
  2. 编辑默认的 CalendarView 组件(反射) - 强烈建议不要采用这种方法,因为它很容易因 SDK/软件更新而中断
  3. 使用第三方库,例如Material CalendarView
© www.soinside.com 2019 - 2024. All rights reserved.