开发者

Transparent ListView selector does not appear

I have a custom ListView selector:

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

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_enabled="false" android:state_focused="true"
        android:drawable="@drawable/stocks_gradient" />
  <item android:state_pressed="true"
        android:drawable="@drawable/titlebar_gradient" />
  <item android:state_focused="true"
        android:drawable="@drawable/titlebar_gradient" />
</selector>

Here is my gradient:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient 
        android:startColor="#FF600D0B"
        android:endColor="#FF89130A"
        android:angle="90"
        android:dither="true"
     />
</shape>

Here is my Layout:

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/streamRelativeLayout">
        <ListView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/streamListView" android:cacheColorHint="#00000000" android:fadingEdge="none" android:drawSelectorOnTop="true" android:listSelector="@drawable/swipe_view_selector"></ListView>
        <TextView android:layout_centerInParent="true" android:layout_height="wrap_content" android:id="@+id/noStreamTextView" android:layout_width="wrap_content" android:text="No Stream Available" android:visibility="invisible"></TextView>
        <ProgressBar android:layout_centerInParent="true" android:layout_height="wrap_content" android:id="@+id/streamProgressBar" android:layout_width="wrap_content"></ProgressBar>
    </RelativeL开发者_开发百科ayout>

The selector appears when the color is opaque, but when I add transparency to the gradient, it doesn't appear. How can I make my gradient transparent so that it appears on the listview?


I'm not following really what you need, bu the answer to the last sentence, is to change

    android:startColor="#FF600D0B"
    android:endColor="#FF89130A"

To some transparent (maybe not fully transparent?) color. Change the first two hex digits (FF) to anything lower. That is the alpha of the color, so android:startColor="#00600D0B" will make it completely transparent, while android:startColor="#88600D0B" will make create a 50% opacity.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜