透明ListView无法正常工作

时间:2015-02-17 13:50:26

标签: android

在主要活动中我有一个lisview ..我想让listview透明,使得主要活动上的图像显示为listview的背景。我试图制作listview的背景知识:android:background =“@ color / transparent “android:cacheColorHint =”#00000000“ 但没有变化

1 个答案:

答案 0 :(得分:0)

在XML中使用根布局的背景属性,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#FFFF00"
  android:orientation="vertical" >

  <ListView
      android:id="@+id/listView"
      android:layout_width="match_parent"
      android:layout_height="match_parent" >
  </ListView>
</LinearLayout>

和一个简单的ArrayAdapter:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.systems));
listView.setAdapter(adapter);

给了我一个透明的listView,我可以看到我选择的背景颜色。希望它有所帮助。

注意:在4.3

上测试
相关问题