3

I have a collapsingToolbarLayout with a calendar inside it. The title of the toolbar is the current month selected. (It's identical to the google calendar mobile app).

When swiping from month to month the title changes. I'm doing this with a Textswitcher. I have an arrow drawable inside the textView (which i add from inside the code) next to the title which I want to rotate when collapsing and expanding the calendar.

My code is as follows:

<TextSwitcher
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/date_title"
    android:layout_gravity="center_vertical">
    <TextView
        android:textColor="@android:color/white"
        android:maxLines="1"
        android:id="@+id/main_title"
        android:ellipsize="end"
        android:layout_gravity="center_vertical"
        android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <TextView
        android:textColor="@android:color/white"
        android:maxLines="1"
        android:ellipsize="end"
        android:id="@+id/main_title_2"
        android:layout_gravity="center_vertical"
        android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</TextSwitcher>

And I add the arrow by doing:

arrow = ContextCompat.getDrawable(context!!,R.drawable.ic_arrow_drop_down_white)!!
mainTitle = toolbarTitle.main_title
secondTitle = toolbarTitle.main_title_2
mainTitle.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_arrow_drop_down_white,0)
secondTitle.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_arrow_drop_down_white,0)

How to I rotate the arrow?

0 Answers0