1

我有一个自定义对话框,它扩展了 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 代码来自 Android,如下所示:

<?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(来自 Android 的那个)上看到它工作正常。我应该怎么做才能解决这个问题?

谢谢

4

1 回答 1

0

试试这个:从这一行中删除“android”文本。像;

android:background="@drawable/list_selector_background"

在列表视图中添加

android:cacheColorHint="@android:color/transparent"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:fadingEdge="none"

这对我有用

于 2012-11-29T09:56:24.603 回答