12

私は日食でカレンダービューを持っています.今、日付を強調するために1日の外観を変更しようとしています. ここでは便利な方法は見つかりませんでした。週の日付または月の日付全体の外観の変更のみです。では、1 日を強調する可能性はありますか?

また、同じ問題を抱えた 3 つの投稿があることも知っていますが、いずれも回答がありませんでした。

4

2 に答える 2

9

ネイティブの CalenderView を拡張して独自の CustomCalendarView を作成し、外観に必要な変更を加えることができます。

ネイティブの CalendarView のコードは、こちら にあります

于 2013-04-08T08:38:48.600 に答える
4

の子ビューを取得し、CalendarViewそこで構成を変更することで、それを行うことができます。

    final CalendarView calendar = new CalendarView(this);       
    java.lang.reflect.Field field = null;

    Class<?> cvClass = calendar.getClass();
    try {
        field = cvClass.getDeclaredField("mDayNamesHeader");    
        field.setAccessible(true);
    } catch (NoSuchFieldException e) {
    }

    ViewGroup tv = null;
    try {
        tv = (ViewGroup) field.get(calendar);
    } catch (IllegalAccessException e) {} 
      catch (IllegalArgumentException ){}

    TextView k =  (TextView) tv.getChildAt(1);
    k.setTextColor(Color.RED);

ここですべての宣言を見つけることができます:

https://android.googlesource.com/platform/frameworks/base/+/2888524e03896831f487e5dee63f18f1c33c0115/core/java/android/widget/CalendarView.java

于 2015-02-04T14:16:38.257 に答える