Search code examples
androidimageimagebuttonrollover

Roll over image of image button


Can anybody suggest me how to roll over the image of the image button when clicked on it? I mean I need the sample

Thanks


Solution

  • use selector like this:

    <?xml version = "1.0" encoding = "utf-8" ?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" android:drawable="@drawable/image" />
        <item android:state_focused="true" android:drawable="@drawable/image" />
        <item android:state_selected = "true" android:drawable = "@drawable/image" />
        <item android:drawable = "@drawable/defaultimage" />
    </selector>
    

    save it in yourselectorname.xml and use it in place of image...