0

我需要标准 Android 搜索按钮的图标 - 镜头 - 具有正常、聚焦、按下 3 种状态。任何人都可以为我提供这个具有 3 个状态的图标吗?

问候,

4

1 回答 1

1

它可以在 Android 中自动进行。根据例子。您可以用任何图像文件替换“state_orange”:

供您控制:

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>

背景07.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>
于 2011-11-10T08:59:54.220 回答