【问题标题】:Android - ListView list selector doesn't use defaultAndroid - ListView 列表选择器不使用默认值
【发布时间】:2011-02-26 18:43:49
【问题描述】:

我正在为我的 ListView 使用我自己的选择器,但不使用默认选择器。你应该如何设置默认的背景drawable?使用下面的代码,我希望我的所有列表行在聚焦或按下之前都是蓝色的。

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

    <item android:state_pressed="true" >
        <shape>
            <gradient
                android:startColor="#0266e9"
                android:endColor="#0484f2"
                android:angle="90" />

        </shape>
    </item>

    <item android:state_focused="true" >
        <shape>
            <gradient
                android:startColor="#bbccff"
                android:endColor="#dce4fd"
                android:angle="90" />                                
        </shape>
    </item>


    <item>        
        <shape>
            <solid android:color="#FF0000FF"></solid>
        </shape>
    </item>
</selector>

【问题讨论】:

标签: android selector


【解决方案1】:

可能是默认(蓝色)不可见:http://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html#attr_android:visible

根据文档,可见性最初是错误的。

【讨论】:

  • 嗯,我只是尝试将其设置为 true:&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:drawable="@drawable/gradient" android:visible="true" /&gt; &lt;/selector&gt;,但它从未出现过。它最初是在按下时显示的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 2014-11-08
相关资源
最近更新 更多