Поэтому я пытаюсь показать / скрыть просмотр календаря по нажатию кнопки. Но в итоге показываю только белый макет.
// xml
<android.support.constraint.ConstraintLayout
android:id="@+id/header_view"
android:elevation="@dimen/height4"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CalendarView
android:background="@color/white"
android:visibility="invisible"
app:layout_constraintTop_toBottomOf="@+id/date_view"
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:paddingBottom="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent">
</CalendarView>
<android.support.constraint.ConstraintLayout
android:background="@color/white"
android:id="@+id/date_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//some other layouts
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
Я знаю, потому что я установил фон календаря на белый, но содержимое также должно отображаться.Проверьте выходное изображение
Но когда я показываю просмотр календаря напрямую (устанавливая видимость видимым), он работает отлично, ТАК что в xml нет проблем.
Вот как я обрабатываю шоу / скрытие календаря
private void setUpCalenderView() {
isCalenderVisible=!isCalenderVisible;
if (isCalenderVisible){
//((CalendarView) findViewById(R.id.calendarView)).setVisibility(View.VISIBLE);
((CalendarView) findViewById(R.id.calendarView)).setVisibility(View.VISIBLE);
}
else{
((CalendarView) findViewById(R.id.calendarView)).setVisibility(View.INVISIBLE);
}
}
Редактировать:
Это суть кода: https://gist.github.com/ankurtagtaste/692335e71ed0576b1e852292536d0ebf