gpt4 book ai didi

android - 如果背景不透明,ListViewItem 不会突出显示

转载 作者:太空狗 更新时间:2023-10-29 16:10:16 24 4
gpt4 key购买 nike

我有一个带有自定义渐变背景的 ListViewItem。默认选择器不再突出显示这些行。

只有当我将背景设置为透明时,突出显示才有效。如果不进行此更改,我如何获得亮点?

这是我的 ListView :

<ListView android:id="@+id/symbolsListView"
android:layout_width="fill_parent"
android:background="@drawable/transparent_background"
android:layout_height="390dp"
android:divider="@drawable/ui_divider_line"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/blue"
android:drawSelectorOnTop="true"
>

最佳答案

你的一些状态是 focused 和 window_focused。下面我提到了选择器的代码试试这个。

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

<item android:state_window_focused="false" android:drawable="@color/transparent" />

<!--
Even though these two point to the same resource, have two states so
the drawable will invalidate itself when coming out of pressed state.
-->
<item android:state_focused="true" android:state_enabled="false"
android:state_pressed="true" android:drawable="@color/transparent" />
<item android:state_focused="true" android:state_enabled="false"
android:drawable="@color/transparent" />

<item android:state_focused="true" android:state_pressed="true"
android:drawable="@color/solid_red" />
<item android:state_focused="false" android:state_pressed="true"
android:drawable="@color/solid_red" />

<item android:state_focused="true" android:drawable="@color/solid_red" />

</selector>

希望它有用。

关于android - 如果背景不透明,ListViewItem 不会突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3809107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com