CalendarView does not respond to xml markup. Except background, nothing works.

<CalendarView android:layout_height="match_parent" android:layout_width="match_parent" android:background="@color/colorBackground" android:selectedWeekBackgroundColor="@color/colorPrimaryDark"> 

Colors colorBackground and colorPrimaryDark are significantly different and it is impossible not to notice the difference. It also does not respond to

 android:focusedMonthDateColor="@color/colorBackgroundDark" android:shownWeekCount="5" 

and other properties ... I'm testing on a real device API 22 ANDROID 5.1

And yes, here's another ... How to change the display method (so that only one month was visible and not two and a half) I thought about increasing the font ... but again DOES NOT REACT

Screenshot

    1 answer 1

    Start by LinearLayout CalendarView in LinearLayout

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/LinearLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <CalendarView android:id="@+id/calendarView" android:layout_width="match_parent" android:layout_height="match_parent" android:onClick="onClick" android:selectedWeekBackgroundColor="#ff0000" android:weekNumberColor="#0000ff" android:weekSeparatorLineColor="#00ff00" /> </LinearLayout> 

    The date can be tracked through the setOnDateChangeListener() method:

     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); CalendarView calendarView = (CalendarView) findViewById(R.id.calendarView); calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() { @Override public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) { int mYear = year; int mMonth = month; int mDay = dayOfMonth; String selectedDate = new StringBuilder().append(mMonth + 1) .append("-").append(mDay).append("-").append(mYear) .append(" ").toString(); Toast.makeText(getApplicationContext(), selectedDate, Toast.LENGTH_LONG).show(); } }); } 
    • but he is already in LinearLayout ... - Denis