Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow layout animation of the calendar view when switching between week and month modes #341

Closed
chuks opened this issue Jun 8, 2016 · 5 comments

Comments

@chuks
Copy link

chuks commented Jun 8, 2016

Currently, when you call setCalendarDisplayMode(CalendarMode.MONTHS) or setCalendarDisplayMode(CalendarMode.WEEKS), the layout jumps between the views, making it look very abrupt. It would be great to enable layout changes, perhaps using enableTransitionType(LayoutTransition.CHANGING) or in xml android:animateLayoutChanges="true"

@chuks chuks changed the title Allow layout animation of the calendar view when setting week or month mode Allow layout animation of the calendar view when switching between week and month modes Jun 8, 2016
@ekchang
Copy link
Contributor

ekchang commented Jun 8, 2016

#278 (comment)

You can apply animateLayoutChanges="true" to the parent layout and setting LayoutTransition#enableTransitionType(CHANGING). Because these are things that apply to the parent ViewGroup of MCV (and not MCV itself), it is not within the scope of changes we can apply to MCV.

@chuks
Copy link
Author

chuks commented Jun 9, 2016

Oh I've tried that, @ekchang, but that doesn't work. It still jumps between month and week view. I'd like a smooth scroll. I think it can be done within the ViewGroup holding the calendar view within the library itself (I suppose it's a viewpager?). I have tried something like this, but that doesn't work:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/content"
    android:orientation="vertical"
    android:background="@color/white"
    android:animateLayoutChanges="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <View
        android:id="@+id/top_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"/>

    <com.prolificinteractive.materialcalendarview.MaterialCalendarView
        android:id="@+id/calendar"
        android:layout_below="@+id/top_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:mcv_selectionColor="@color/white"
        app:mcv_dateTextAppearance="@style/CustomTextAppearance"
        app:mcv_headerTextAppearance="@style/CustomHeaderTextAppearance"
        app:mcv_weekDayTextAppearance="@style/CustomWeekDayTextAppearance"
        app:mcv_showOtherDates="none"/>

</RelativeLayout>

@chuks
Copy link
Author

chuks commented Jan 14, 2017

@ekchang this does not work. I think it needs to be enabled from within the library itself.

@AkhilDad
Copy link

@chuks It doesn't work because it changes the adapter, I am struggling with the same.
Any idea if one can apply animation while setting/removing the adapter to viewpager?
I am unable to find out a way to do that

@chuks
Copy link
Author

chuks commented Apr 24, 2017

Aha , that makes sense. One way would be to put the calendar view inside a LinearLayout that has animateLayoutChanges set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants