Android 自定义视图中带有9个面片图像背景的选择器

Android 自定义视图中带有9个面片图像背景的选择器,android,android-listview,selector,android-selector,Android,Android Listview,Selector,Android Selector,我在自定义视图中实现选择器时遇到问题。我已经搜索了1个小时,但我找不到解决方案。我有imageview的自定义视图,一些文本视图和九块背景,但问题是当它处于按下状态时,选择器的颜色不覆盖图像视图 对于实现,我正在为布局使用背景选择器,我只需在按下和未按下状态下更改9面片图像,然后在listview中禁用默认选择器 你有更好的解决办法吗?我在google play中看到,蓝色选择器覆盖了所有视图,这就是我想要的 对于xml <?xml version="1.0" encoding="ut

我在自定义视图中实现选择器时遇到问题。我已经搜索了1个小时,但我找不到解决方案。我有imageview的自定义视图,一些文本视图和九块背景,但问题是当它处于按下状态时,选择器的颜色不覆盖图像视图

对于实现,我正在为布局使用背景选择器,我只需在按下和未按下状态下更改9面片图像,然后在listview中禁用默认选择器

你有更好的解决办法吗?我在google play中看到,蓝色选择器覆盖了所有视图,这就是我想要的

对于xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/touch_selector"
    android:orientation="horizontal"
    android:padding="16dp" >

    <ImageView />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView />

        <TextView />
    </LinearLayout>

</LinearLayout>

和触摸选择器

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/card_background_pressed" android:state_focused="true"/>
    <item android:drawable="@drawable/card_background_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/card_background_white" android:state_focused="false" android:state_pressed="false"/>

</selector>

其中card_背景为9补丁图像

编辑:

这是google play的一个例子


接受的数据不正确。 可以在选择器中使用九条路径,只需使用。大概是这样的:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true">
        <nine-patch 
            android:src="@drawable/marker"/>
    </item>
    <item>
        <shape>
            <solid android:color="#000000" />
        </shape>
    </item>
</selector>


选择器的颜色不覆盖图像视图
您的意思是绿色选择器应覆盖整个列表项,还是图像本身应具有绿色背景?是的,绿色选择器应覆盖整个列表项。它看起来像项目顶部的绿色选择器,不透明度为50%。伟大的例子就像谷歌播放列表项目。你能发布谷歌播放列表项目示例的屏幕截图吗?因为我真的看不到你想要达到什么目的。我真的很抱歉我的英语不好。这是google play的一个例子。Google play有很棒的选择器,因此触摸反馈可以覆盖图像视图。看这里:你的问题有点错,但你只回答我的问题kkk