Why is 0dp considered a performance enhancement?

First of all you have this,

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1">
</ListView>

Never take the ListView’s height as wrap_content, that will lead into troubles. Here is the reason for that and this answer.

Further more,

I searched around but haven’t found anything that really explains why
Android Lint as well as some Eclipse hints suggests replacing some
layout_height and layout_width values with 0dp.

Its because you are using layout_weight = "1" that means your ListView with take the height as much as is available to it. So, in that case there is no need of using layout_height = "wrap_content" just change it to android:layout_height="0dp" and ListView’s height will be managed by layout_weight = "1".

Leave a Comment