Applandeo / Material-Calendar-View

Material Calendar View for Android
Apache License 2.0
975 stars 316 forks source link

Using calendar in jetpack compose #451

Open tchouaffe opened 1 year ago

tchouaffe commented 1 year ago

Is it possible to use this calendar within jetpack compose? I am getting an error doing so.

<?xml version="1.0" encoding="utf-8"?>
  <androidx.constraintlayout.widget.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <com.applandeo.materialcalendarview.CalendarView
        android:id="@+id/calendar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:headerColor="@color/colorPrimary"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:todayLabelColor="@color/colorAccent" />

  </androidx.constraintlayout.widget.ConstraintLayout>

Compose code:

@Composable fun MaterialCalendar() { val color = MaterialTheme.colorScheme.surface.toArgb() AndroidViewBinding(CalendarViewBinding::inflate) { calendar.setBackgroundColor(color) } }

exception:

Throwing OutOfMemoryError "Failed to allocate a 430032 byte allocation with 297064 free bytes and 290KB until OOM, target footprint 201326592, growth limit 201326592" (VmSize 33280556 kB, recursive case)