2012-01-12 84 views
0

我在使用透明度设置列表背景时遇到问题。我无法设置透明度。ListView透明度

这里是我的代码:

<ListView android:id="@+id/players_list" android:layout_width="fill_parent" 
    android:layout_below="@+id/players_text" android:layout_height="wrap_content" 
    android:cacheColorHint="#00000000" android:background="#00000000"> 
</ListView> 

在我的活动:

ListView list = (ListView) findViewById(R.id.players_list); 
    ArrayList<HashMap<String, Object>> mylist = new ArrayList<HashMap<String, Object>>(); 
    HashMap<String, Object> map1 = new HashMap<String, Object>(); 
    map1.put("field1", "John Doe"); 
    map1.put("field2", "2342"); 
    mylist.add(map1); 
    HashMap<String, Object> map2 = new HashMap<String, Object>(); 
    map2.put("field1", "Simina Dorin"); 
    map2.put("field2", "10000"); 
    mylist.add(map2); 

    SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, 
      R.layout.online_players_row, 
      new String[] { "field1", "field2" }, new int[] { 
        R.id.players_text, R.id.score_text }); 

    list.setAdapter(mSchedule); 

有何意见?


发现了问题: 我不得不为我设置列表的列布局像一个背景:机器人:背景= “#80439197”

+0

http://stackoverflow.com/questions/1377336/how-to-make-a-listview-transparent-in-android – 2012-01-12 11:34:00

+1

你面临的问题是什么?你期待的结果是什么? – Nitin 2012-01-12 11:34:17

+0

http://community.developer.motorola.com/t5/Android-App-Development-for/ListView-transparent-background/td-p/13650 – Vamsi 2012-01-12 11:42:33

回答

0

试试这个

android:background="@android:color/transparent" 
+0

我已经在这里发布了一个解决方案:http://stackoverflow.com/questions/16560448/android-transparent-colour-listviews-with-background/38368774#38368774 – user2288580 2016-07-14 08:10:56

0

这就是你需要按here提及并解释here

android:background =“@ drawable/bg” and固醇:cacheColorHint = “#00000000”

+0

我已经在这里发布了一个解决方案:http://stackoverflow.com/questions/16560448/android-transparent-colored-listviews-with -background/38368774#38368774 – user2288580 2016-07-14 08:14:46

0

这就是你需要做什么提到here和解释here

的android:背景= “@色/透明” 机器人:cacheColorHint = “#00000000”