【发布时间】:2020-02-25 04:37:05
【问题描述】:
我有一个带有自定义 ArrayAdapter 的 ListView。这些项目在 Android 7.0+ 上正确显示,但在 6.0 上不正确。在后一种情况下,文本几乎不可见,因为 Android 默认将其设置为白色。
奇怪的是,我在这个项目中也有回收站视图,项目布局完全相同,并且以深色文本正确显示!
除了明确设置颜色之外,有没有人遇到过这个问题并且知道如何正确解决它?
这是ListView的布局
<?xml version="1.0" encoding="utf-8"?>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".books.BooksFragment"/>
和项目布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:textSize="18sp" />
</RelativeLayout>
【问题讨论】: