首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自定义对话框上的Android Trackball

自定义对话框上的Android Trackball
EN

Stack Overflow用户
提问于 2012-11-29 17:33:24
回答 1查看 216关注 0票数 1

我有一个自定义对话框,它扩展了dialog类和一个简单的自定义布局,如下图所示:

代码语言:javascript
复制
<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代码来自安卓,看起来像这样:

代码语言:javascript
复制
<?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. -->

代码语言:javascript
复制
<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代码是这样的:

代码语言:javascript
复制
<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 (安卓系统的那个)上看到工作正常。我应该怎么做才能解决这个问题?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-29 17:56:25

试试这个:从该行中删除"android“文本。喜欢;

代码语言:javascript
复制
android:background="@drawable/list_selector_background"

在列表视图中添加

代码语言:javascript
复制
android:cacheColorHint="@android:color/transparent"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:fadingEdge="none"

这件很适合我

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13622674

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档