0

I have a problem setting a list's background with transparency. I'm unable to set transparency.

Here is my code:

<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>

In my activity:

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);

Any advices?


Found the problem: I had to set my list's row layout with a background like: android:background="#80439197"

dorin
  • 873
  • 2
  • 15
  • 34

2 Answers2

0

try this

android:background="@android:color/transparent"
Vamshi
  • 1,495
  • 1
  • 15
  • 31
  • I've posted a solution here: http://stackoverflow.com/questions/16560448/android-transparent-colored-listviews-with-background/38368774#38368774 – user2288580 Jul 14 '16 at 08:10
0

This is what you need to do as mentioned here and explained here

android:background="@color/transparent" android:cacheColorHint="#00000000"

Community
  • 1
  • 1
Nitin
  • 1,451
  • 13
  • 17