如果受主题颜色影响,列表视图的颜色

color of list view if affected by color of theme

我已经为activity定义了一个主题,这里的背景颜色是#67b4ef。

  <style name="CustomTheme" parent="android:Theme">
  <item name="android:windowTitleSize">100dip</item>
  <item name="android:background">#67b4ef</item>
  <item name="android:textColor">#ffffff</item>
  <item name="android:textSize">20dip</item>
  </style>

这个 activity 有一个应该是白色的列表视图,我将它的背景设置为:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" android:background="#ffffff">

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:divider="@null"
        android:dividerHeight="0dip"
        android:focusable="false"
        android:focusableInTouchMode="false" >
    </ListView>

</LinearLayout>

但列表视图的颜色受主题背景颜色的影响。我不要这个。

列表视图:

             lv=(ListView) findViewById(R.id.listView1);

发生此问题是因为您正在使用 默认 android 适配器 .....

使用自定义适配器并更改列表项颜色

使用这个linkCustom ListView

如果您介于两者之间 Custom ListView 请在评论中提问。

享受编码......

不要将ListView 的背景设置为#ffffff,而应将Listview 中每个项目的背景设置为#ffffff。

您原来的方法会发生什么,您的 ListView 背景是#ffffff。但是,ListView 上的所有项目视图都具有主题 (#67b4ef) 的默认背景。因此,您在屏幕上看到的背景就是主题背景。