Implement CoolSwitch in your Android layout
masterCoolSwitch provides a custom view with a reveal animation for switching between two states. To implement it, follow these two steps:
1. Include the CoolSwitch view
Add the com.serchinastico.coolswitch.CoolSwitch view to your layout. You must specify which views will be displayed for each state using the following custom attributes:
coolswitch:disabledView: The ID of the view to show when the switch is in the disabled state.coolswitch:enabledView: The ID of the view to show when the switch is in the enabled state.
Important: If either view is undefined, the animation will not play.
2. Wrap animated views in a Target container
To enable the animation, you must wrap the views being switched (the disabledView and enabledView) inside either a TargetFrameLayout or a TargetLinearLayout.
<!-- 1. The Switch View -->
<com.serchinastico.coolswitch.CoolSwitch
android:id="@+id/cool_switch_foo"
android:layout_height="35dp"
android:layout_width="60dp"
coolswitch:disabledView="@id/disabled_view_foo"
coolswitch:enabledView="@id/enabled_view_foo"/>
<!-- 2. The Container and the Views to be animated -->
<com.serchinastico.coolswitch.TargetFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/disabled_view_foo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"/>
<LinearLayout
android:id="@+id/enabled_view_foo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00FF00"/>
</com.serchinastico.coolswitch.TargetFrameLayout>