小编Val*_*tin的帖子

如何更改 CalendarView 中的月份文本颜色

我在我的项目中使用CalendarView,我需要对其进行特殊的设计。我可以更改 CalendarView 中所有内容的颜色,但只能更改日历顶部月份的颜色。我尝试了xml中的所有属性。如何更改月份铭文和箭头的颜色?

<CalendarView
        android:id="@+id/calendarID"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="Heh"
        android:maxDate="31/12/2018"
        android:minDate="09/01/2012"
        android:showWeekNumber="false"
        android:focusedMonthDateColor="@android:style/TextAppearance.Small"
        android:background="#004366"
        android:unfocusedMonthDateColor="@android:style/TextAppearance.Small"
        android:dateTextAppearance="@android:style/TextAppearance.Small"
        android:weekDayTextAppearance="@android:style/TextAppearance.Small"
        android:weekSeparatorLineColor="@android:style/TextAppearance.Small"
        android:selectedWeekBackgroundColor="@android:style/TextAppearance.Small"
        />
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

 LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
            (Context.LAYOUT_INFLATER_SERVICE);

    LinearLayout ll= (LinearLayout)inflater.inflate(R.layout.calendar_moi, null, false);

    CalendarView cv = (CalendarView) ll.getChildAt(0);
    Long maxData = System.currentTimeMillis();
    cv.setMaxDate(maxData);

    cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month,
                                        int dayOfMonth) {


        }
    });

    new AlertDialog.Builder(ItemClassActivity.this)
            .setTitle("")
            .setMessage("")
            .setView(ll)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-view calendarview android-styles

6
推荐指数
2
解决办法
5227
查看次数