Activating Android L Animation Elements

There are a lot of cool animations in the preview of Android L, I am especially interested in animating action elements inside ActionBar. Here's a video of this animation from a Google Material Design webpage. Does anyone know how to implement this animation?

+4
source share
1 answer

You can create animated icons based on frames using the <animation-list> XML element or the AnimationDrawable class. Starting with L, you can create state-based animated icons using the <animated selector> XML element or the AnimatedStateListDrawable class.

L:

<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:state_checked="true">
        <bitmap android:src="@drawable/btn_check_to_on_mtrl_015"
                android:tint="?attr/colorControlActivated"
                android:alpha="?attr/disabledAlpha" />
    </item>
    <item android:state_enabled="false">
        <bitmap android:src="@drawable/btn_check_to_on_mtrl_000"
                android:tint="?attr/colorControlNormal"
                android:alpha="?attr/disabledAlpha" />
    </item>
    <item android:state_checked="true" android:id="@+id/on">
        <bitmap android:src="@drawable/btn_check_to_on_mtrl_015"
                android:tint="?attr/colorControlActivated" />
    </item>
    <item android:id="@+id/off">
        <bitmap android:src="@drawable/btn_check_to_on_mtrl_000"
                android:tint="?attr/colorControlNormal" />
    </item>
    <transition android:fromId="@+id/off" android:toId="@+id/on">
        <animation-list>
            <item android:duration="15">
                <bitmap android:src="@drawable/btn_check_to_on_mtrl_000"
                        android:tint="?attr/colorControlActivated" />
            </item>
            ...

, PNG, , "off" "on", PNG. , 15 "" " " .

< > .

+4

Source: https://habr.com/ru/post/1547580/


All Articles