In some of the popular chat applications like whatsapp or hangouts, there is a button which can be transformed into a record button and also when you enter some text it will transform into a send button.
AnimButton is a custom ImageButton which is imitating the whatsapp’s send button behavior. Basically, it will change the image source when you enter some text on the edittext and it will go back when you clear the edittext
In this post I will try to mimic this behavior in my AnimButton project. Also, the full source code of the project can be found on the Github.
I want to introduce the AnimButton.java class to you:
To use the anim button in your layout you simple set the custom attributes of first and second drawables like so:
<com.gunhansancar.android.animbutton.AnimButton android:id="@+id/animButton" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_width="50dp" android:layout_height="50dp" app:first="@drawable/ic_mic" app:second="@drawable/ic_send" />
And here you can see the AnimButton in action: