ListViewItem的没有得到强调,如果背景是不是透明 [英] ListViewItem does not get highlighted if the background isn't transparent
本文介绍了ListViewItem的没有得到强调,如果背景是不是透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义渐变背景的ListViewItem。默认选择不再突出了这些行了。
如果我将背景设置为透明高亮才有效。我怎样才能获得的亮点没有这种变化?
下面是我的ListView:
< ListView的机器人:ID =@ + ID / symbolsListView
机器人:layout_width =FILL_PARENT
机器人:背景=@绘制/ transparent_background
机器人:layout_height =390dp
机器人:分=@绘制/ ui_divider_line
机器人:cacheColorHint =#00000000
机器人:listSelector =@绘制/蓝
机器人:drawSelectorOnTop =真
>
解决方案
您一些国家是专注和window_focused。下面我提到的code的选择尝试。
<?XML版本=1.0编码=UTF-8&GT?;
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android> <项目的android:state_window_focused =false的机器人:可绘制=@色/透明/> <! -
即使这两个指向相同的资源,具有两种状态,以便
出来的pressed状态的时候,将绘制本身无效。
- >
<项目的android:state_focused =真正的机器人:state_enabled =假
机器人:STATE_ pressed =真正的机器人:可绘制=@色/透明/>
<项目的android:state_focused =真正的机器人:state_enabled =假
机器人:可绘制=@色/透明/> <项目的android:state_focused =真正的机器人:STATE_ pressed =真
机器人:可绘制=@色/ solid_red/>
<项目的android:state_focused =false的机器人:STATE_ pressed =真
机器人:可绘制=@色/ solid_red/> <项目的android:state_focused =真正的机器人:可绘制=@色/ solid_red/>< /选择>
希望工程。
I have a ListViewItem with a custom gradient background. The default selector no longer highlights these rows anymore.
Highlight only works if I set the background to transparent. How can I get the highlight without this change?
Here is my 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"
>
解决方案
your some states that are focused and window_focused. Below i mentioned the code for selector try this.
<?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>
Hope it works.
这篇关于ListViewItem的没有得到强调,如果背景是不是透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文