Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is actually an easy solution to this problem using basic layouts implemented completely in the .xml layout file.</p> <p>First off, the Motorola blog suggestion is not acceptable because it requires building to API v2.3 in order to use '<code>android:overScrollFooter</code>' forcing either multiple builds or inaccessibility to the majority of Android devices.</p> <p>The suggestion to set the ListView's <code>android:layout_height="wrap_content"</code> does work in many cases and is very useful if there are no layout items below the ListView.</p> <p>The problem occurs when there are one or more View's above and one or more View's below the ListView. This requires setting both <code>android:layout_below</code> and <code>android:layout_above</code> for the ListView, which stretches the height of the ListView to the height of the available space which is bigger than the necessary '<code>wrap_content</code>'. When this happens, the "Bug" kicks in - the extra space at the bottom of the ListView is filled with the footer's default background color which is dark gray and not transparent.</p> <p><strong>Now for the simple solution</strong>.</p> <p>Place the ListView inside of a vertical LinearLayout or equivalent. Allow the LinearLayout to span from top to bottom of the available space with <code>height="fill_parent"</code>, the extra will be filled with the correct background drawable or color. Set the height of the ListView to <code>"wrap_content"</code> so there is no unused space for the unsightly gray footer background.</p> <p>Here is an example:</p> <pre><code>&lt;Button&gt; android:id=@+id/MyTopButton" ... &lt;/Button&gt; &lt;Button&gt; android:id=@+id/MyBottomButton" android:layout_alignParentBottom="true" ... &lt;/Button&gt; &lt;LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" android:layout_below="@+id/MyTopButton" android:layout_above="@+id/MyBottomButton" &gt; &lt;!-- Note: This is a bug fix for a particular problem experienced on Motorola OS v2.3.3 devices only in which the space below the unused portion of the ListView is rendered in gray instead of the desired transparent 'cacheColorHint' color. This solution which wraps the ListView in another container (a LinearLayout in this case) allows the ListView to be of height "wrap_content" while the parent container is forced to be the desired height - namely from the header area above down to the buttons below. --&gt; &lt;ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/MyList" android:cacheColorHint="#00000000" /&gt; &lt;/LinearLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload