我有一个自定义对话框,它扩展了dialog类和一个简单的自定义布局,如下图所示:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:drawable/list_selector_background"
>
<TextView
android:id="@+id/text_view"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:background="@color/transparent"
android:textColor="@color/black"
android:textSize="16sp"
android:focusable="true"/>
我的问题是,跟踪球使文本不可见,当一行被选中时,就像附加的图像一样。

list_selector_background代码来自安卓,看起来像这样:
<?xml version="1.0" encoding="utf-8"?>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
<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="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="true" android:drawable="@drawable/list_selector_background_focus" />
我的ListView xml代码是这样的:
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="true"
android:background="@color/white"
android:cacheColorHint="@color/transparent">
</ListView>我在AlertDialog (安卓系统的那个)上看到工作正常。我应该怎么做才能解决这个问题?
谢谢
发布于 2012-11-29 17:56:25
试试这个:从该行中删除"android“文本。喜欢;
android:background="@drawable/list_selector_background"在列表视图中添加
android:cacheColorHint="@android:color/transparent"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:fadingEdge="none"这件很适合我
https://stackoverflow.com/questions/13622674
复制相似问题