Question

So I have a ListView. The items have their own drawable.

The divider is also its own drawable.

Now, when I have a ListView, as seen in the screenshot below, the empty area without enough elements to fill, it's just white.

Screenshot

I've tried setting the cache color hint, but this doesn't solve it (Honestly can't think of anything else that may be wrong with it).

Any help is appreciated.

Adding some code...

My ListView creation and properties:

    final ListView v = new ListView(this.getActivity());
    fl.setBackgroundColor(Color.TRANSPARENT);
    v.setBackgroundDrawable(this.getActivity().getResources().getDrawable(R.drawable.item_selector_bad));
    v.setDivider(new ColorDrawable(Color.parseColor("#00000000")));
    v.setDivider(this.getActivity().getResources().getDrawable(R.drawable.item_square));
    v.setCacheColorHint(Color.TRANSPARENT);
    v.setSelector(this.getActivity().getResources().getDrawable(R.drawable.item_selector_bad));
    v.setDividerHeight(20);

As for xml files, the general layout is such

A item in the list has:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/item_square">
    </item>
    <item android:drawable="@drawable/item_green">
    </item>
</layer-list>

The item_square is just:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/light_grid"
    android:tileMode="repeat" >

</bitmap>

The item_green:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid android:color="@color/light_green" />


    <corners
        android:bottomLeftRadius="25dp"
        android:bottomRightRadius="25dp"
        android:topLeftRadius="25dp"
        android:topRightRadius="25dp" />

</shape>
Was it helpful?

Solution

So, I thought of this solution, however, I read that it has a performance hit. I imagine it's not that bad, and if it is, I'll be sure to re-post and add a bounty. However, you basically just make the ListView use wrap content for the height.

White Space around List View Items

Their are many more questions similar to this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top