{"id":377,"date":"2011-03-30T12:40:25","date_gmt":"2011-03-30T12:40:25","guid":{"rendered":"http:\/\/www.gmarwaha.com\/blog\/?p=377"},"modified":"2014-09-14T04:48:08","modified_gmt":"2014-09-14T04:48:08","slug":"android-list-view-alternating-between-1px-and-2px-dividers","status":"publish","type":"post","link":"https:\/\/www.gmarwaha.com\/blog\/2011\/03\/30\/android-list-view-alternating-between-1px-and-2px-dividers\/","title":{"rendered":"Android: List View alternating between 1px and 2px dividers"},"content":{"rendered":"<p>Have you faced a problem with Android ListView where the dividers alternate between 1 pixel and 2 pixel thickness although you have specifically styled it to 1px? I am sure many have, but for some reason they seem to ignore it. I say this because I noticed this problem in quite a few apps in the market. When I found the same problem in one of my apps, I decided to fix it although it was not at the top of my priority list. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_wrong.png\" alt=\"1px_wrong\" title=\"1px_wrong\" width=\"480\" height=\"382\" class=\"aligncenter size-full wp-image-393\" srcset=\"https:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_wrong.png 480w, https:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_wrong-300x238.png 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<p>The first solution I came up with was more of a work-around. Instead of using a 1px divider line, I tried using a 1px thick image as @drawable. It worked out surprisingly well on my HTC Desire but was not without its own problems. On low-end android phones the dividers started to blink when the user scrolls the list. Sometimes they disappeared and never re-appeared. I guess it is some kind of a refresh problem. I even noticed this kind of behaviour in a few market apps. So, that approach didn&#8217;t work out very well&#8230; <\/p>\n<p>Then after quite a bit of fiddling around, I found out the root cause of the problem. My app was running in compatibility mode!!! Man, how could I have not noticed that? Anyway, when I tried setting the minSdkVersion in my android manifest to version 4 and the targetSdkVersion to the version 8 the problem disappeared completely. I could now use a plain 1px divider line and there were no problems. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_right.png\" alt=\"1px_right\" title=\"1px_right\" width=\"480\" height=\"316\" class=\"aligncenter size-full wp-image-389\" srcset=\"https:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_right.png 480w, https:\/\/www.gmarwaha.com\/blog\/wp-content\/uploads\/2011\/04\/1px_right-300x197.png 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/p>\n<pre class=\"prettyprint\">\r\n  &lt;uses-sdk android:minSdkVersion=\"4\"\r\n          android:targetSdkVersion=\"8\"\r\n    \/&gt;\r\n<\/pre>\n<p>I just thought of sharing it with the world just in case someone runs into the same road block&#8230; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you faced a problem with Android ListView where the dividers alternate between 1 pixel and 2 pixel thickness although you have specifically styled it to 1px? I am sure many have, but for some reason they seem to ignore it. I say this because I noticed this problem in quite a few apps in the market. When I found the same problem in one of my apps, I decided to fix it although it was not at the top of my priority list. The first solution I came up with was more of a work-around. Instead of using a... <br \/><a class=\"moretag\" href=\"https:\/\/www.gmarwaha.com\/blog\/2011\/03\/30\/android-list-view-alternating-between-1px-and-2px-dividers\/\">Continue reading...<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,18],"tags":[],"class_list":["post-377","post","type-post","status-publish","format-standard","hentry","category-android","category-mobile"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/comments?post=377"}],"version-history":[{"count":23,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/377\/revisions"}],"predecessor-version":[{"id":799,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/posts\/377\/revisions\/799"}],"wp:attachment":[{"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/media?parent=377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/categories?post=377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gmarwaha.com\/blog\/wp-json\/wp\/v2\/tags?post=377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}