首页 > 代码库 > Android常见错误处理(一)

Android常见错误处理(一)

1、Set android:baselineAligned="false" on this element for better performance

如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算


2、This tag and its children can be replaced by one <TextView/> and a compound drawable

如果我们想用一个TextView和ImageView的组合,并不需要使用这两个组件,只要对TextView使用一个drawable就行了,例如android:drawableTop="....."


3、Missing contentDescription attribute on image

跟Image有关的空间需要一个描述,要解决这个问题的话加上一个空字符或者@string/App_name即可


4、This LinearLayout layout or its LinearLayout parent is possibly useless

在LinearLayout布局当中嵌套了一个子的LinearLayout布局,而在我的这个整个布局文件中是一最外层的LinearLayout为父控件进行整体布局的,从而造成这段布局代码重复了LinearLayout布局。所以只要把多余的LinearLayout去掉就可以了


5、Nested weights are bad for performance

在布局进行嵌套使用时,父布局与子布局都使用了android:layout_weight,但不是必须使用时,便会出现如题所示的警告信息。

Android常见错误处理(一)