A subclass of the Button widget that automatically darkens the button's background drawable when pressed, and sets it to transparent when disabled. This is inspired by iOS' automatic handling of custom background images for buttons.
See the blog post here
-
Copy and paste the
netfolder into your Android project'ssrcfolder. -
Replace your button declarations to use
net.shikii.widgets.SAutoBgButtoninstead of justButton:From this:
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_blue_bg" android:text="Button with background image" />To this:
<net.shikii.widgets.SAutoBgButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_blue_bg" android:text="Button with background image" />
Here's a sample output using this custom button:
