androidandroid-iconsstatelist

Search Icons - lens - with the 3 states


I need the icons of the standard Android search button - lens - with 3 states normal, focused, pressed. could any one provide me with this icons with 3 states?

regards,


Solution

  • It can be automatic in Android. follow the example. you can replace "state_orange" with any image files:

    for your control:

    android:background="@color/back_color_selector_blue_gradient"
    

    back_color_selector_blue_gradient.xml:

    <?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/state_orange" />
        <item android:state_selected="true" android:drawable="@drawable/state_orange" /> <!-- focused -->
        <item android:drawable="@drawable/background07" /> <!-- default -->
    </selector>
    

    background07.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
    
        <item>
            <shape android:shape="rectangle">
                <gradient android:startColor="@color/grayBlue3"
                    android:endColor="@color/lightBlue" android:angle="270"
                    android:centerColor="@color/lightBlue" />
                <!-- border width and color -->
                <stroke android:width="1dp" android:color="#FFDDDDDD" />
                <padding android:left="1dp" android:top="1dp" android:right="1dp"
                    android:bottom="1dp" />
            </shape>
        </item>
    
    </layer-list>
    

    state_orange.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="@color/orange" />
    </shape>