This write-up is dedicated to James, the maker and breaker of things, who last time taught us about controlling out doors with Bluetooth-LE devices. He began this project with a simple desire to design some pretty animated buttons for some pesonal task. As he progressed ahead, he realized what kind of struggles lied ahead and how he could learn so many new things in overcoming those obstacles.
He is not very fond of creating new codes and customizing UI elements by expanding the existing Android classes. So, he browsed a bit and discovered some exceptionally cool functions in Lollipop like VectorDrawable, AnimatedVectorDrawable, AnimatedStateListDrawable, and RippleDrawable. These classes can always be employed in creation of animated buttons. Luckily, none of these functions required code modification. You can always visit some online soources to learn a thing or two about vectors before moving ahead. In order to keep things simple, he adds, he used the ToggleButton for animated buttons. He didn’t use SwitchButton for this purpose because of its hardcoded animations and drawables. The layout for the application has been given in the below given figure:
The thing that needs maximum attention while designing the animation button is the look of animated buttons. Your initial app layout would always define the way those buttons animate. If these are not done carefully, then the ToggleButton would look just like any other normal button and wouldn’t make much impact.
The top most level of his circle button drawable consisted of <layer-list> which allowed him to layer several drawables that could respond to different states. It was a bit troublesome for him to repeat the path for every drawable because there is no way to inherit one drawable from another one. Continuing with that, he included some very simple drawables in <transition> element. The <animated-drawable> element defined the properties that were to animate along with the animation that needed to be applied to those properties
Filed Under: Reviews