Skip to content

Automatic pressed and disabled state for custom Button background images.

License

Notifications You must be signed in to change notification settings

shiki/android-autobgbutton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

SAutoBgButton for Android

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

Usage

  1. Copy and paste the net folder into your Android project's src folder.

  2. Replace your button declarations to use net.shikii.widgets.SAutoBgButton instead of just Button:

    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:

About

Automatic pressed and disabled state for custom Button background images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages