The Source (aka The Illustration Of The Problem)
I have a ListView as follows:
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="0px"
android:listSelector="@android:color/transparent"
android:id="@+id/hellyeah"
/>
Nothing too special about it. It sits inside a RelativeLayout.
The Problem
When running the app, I did notice a line between the list rows. So I hooked a debugger to the process, set a breakpoint on the onClick handler for the list rows, and started playing around in Android Studio's "Expression Evaluation" window:
((ListView) findViewById(R.id.hellyeah)).getDividerHeight();
If you've read the title of this question you'll know the result of this expression: -1.
But didn't I explicitely set it to 0 in the layout XML?
The Solution
Changing "0px" to "0dp" doesn't work. My question is not how to solve this - I could simply call setDividerHeight(0)
and that works.
The Question
My question is: why isn't my android:dividerHeight="0px"
respected? Why do I get a negative divider height?