5
为什么0dp被认为是性能增强?
结合了备注和解决方案,在此问题末尾的答案已经填写完毕。 题 我四处搜寻,但没有找到任何能真正解释Android Lint和Eclipse提示为何建议使用替换掉部分layout_height和layout_width值的东西0dp。 例如,我ListView建议将其更改 之前 <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> </ListView> 后 <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> 同样,它建议对ListView项进行更改。这些更改前后的外观都相同,但是我有兴趣了解为什么这些是性能提升的原因。 有人对此有解释吗?如果有帮助,请使用进行总体布局ListView。 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/logo_splash" android:layout_width="match_parent" android:layout_height="wrap_content"> </ImageView> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@color/background" android:layout_below="@id/logo_splash"> <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_upcoming" /> </LinearLayout> </RelativeLayout> …