开发者

Gallery view selector is not always displayed

开发者 https://www.devze.com 2023-03-12 01:55 出处:网络
I am using a Gallery view in which I use a selector in order to highlight the image I have selected. I basically need to draw a blue rectangle above the selected image. My issue is, this blue image co

I am using a Gallery view in which I use a selector in order to highlight the image I have selected. I basically need to draw a blue rectangle above the selected image. My issue is, this blue image comes and di开发者_开发问答sappears after 3 seconds. At times the blue rectangle is never displayed even if the image is selected. At times, it displays properly.

My selector xml code is:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_pressed="true"
        >
        <shape
            android:shape="rectangle">
            <solid
                android:color="#00000000" />
            <corners
                android:bottomRightRadius="8dp"
                android:bottomLeftRadius="8dp"
                android:topLeftRadius="8dp"
                android:topRightRadius="8dp" />
            <stroke
                android:color="#FFFF00"
                android:width="2dp" />
        </shape>
    </item>
    <item
        android:state_selected="true"
        >
        <shape
                        android:shape="rectangle">
            <solid
                android:color="#00000000" />
            <corners
                android:bottomRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp" />
            <stroke
                android:color="#3366FF"
                android:width="4dp" />
        </shape>
    </item>
    <item>
        <shape

            android:shape="rectangle">
            <solid
                android:color="#00000000" />
            <corners
                android:bottomRightRadius="10dp"
                android:bottomLeftRadius="10dp"
                android:topLeftRadius="10dp"
                android:topRightRadius="10dp" />
            <stroke
                android:color="#c2c2c2"
                android:width="2dp" />
        </shape>
    </item>
</selector>

I use a image loader to load the image:

imageView.setImageResource(R.drawable.galleryselector);

why does this happen?

0

精彩评论

暂无评论...
验证码 换一张
取 消