Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the problem is in your <code>ListView</code>'s <code>layout_width</code> &amp; <code>layout_height</code>.</p> <p>Set <code>layout_width="fill_parent"</code> and <code>layout_height="wrap_content"</code></p> <p>Otherwise</p> <p><strong>Ways to Set Divider Color &amp; Height in Listview</strong></p> <ol> <li><p>You can set this value in a layout xml file using <code>android:divider="#FF0000"</code>. </p></li> <li><p>You should also set/reset the height of the divider when you modify it.</p> <p></p> <pre><code> &lt;ListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:divider="#FFCC00" android:dividerHeight="4px"/&gt; </code></pre> <p></p></li> <li><p>You can also specify a <code>Drawable</code> resource in <code>android:divider</code> as well. </p></li> <li><p>You can code it:</p> <pre><code>int[] colors = {0, 0xFFFF0000, 0}; // red for the example myList.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); myList.setDividerHeight(1); </code></pre></li> <li><p>You can do like</p> <p>Method 1:</p></li> </ol> <p>In res/values/colors.xml, put the following:</p> <pre><code>&lt;resources&gt; &lt;color name="sage"&gt;#cceebb&lt;/color&gt; &lt;/resources&gt; </code></pre> <p>In your <code>ListActivity</code>-extending class, do this:</p> <pre><code>ListView lv = getListView(); ColorDrawable sage = new ColorDrawable(this.getResources().getColor(R.color.sage)); lv.setDivider(sage); lv.setDividerHeight(1); </code></pre> <p>Method 2:</p> <p>In res/values/colors.xml:</p> <pre><code>&lt;resources&gt; &lt;drawable name="sage"&gt;#cceebb&lt;/drawable&gt; &lt;/resources&gt; </code></pre> <p>And in your class that extends ListActivity:</p> <pre><code>ListView lv = getListView(); ColorDrawable sage = new ColorDrawable(this.getResources().getColor(R.drawable.sage)); lv.setDivider(sage); lv.setDividerHeight(1); </code></pre> <p>Hope it helps</p>
 

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