Android常见布局问题

原文链接:http://www.cnblogs.com/Birdmafly/p/3809802.html

好久没写博了,因为最近在忙着做一个app,实在是没有时间。现在快完工了。想着还是把这个布局问题说一下,相信很多人都遇到了,而且但凡是写的稍微复杂一点的layout,遇到的不止一次。

对于一个强迫症的人来说,看见这个2,立马想让它消失。打开lint一看,全是同一个问题,如下:

意思大概是丢失了关于image的说明,那就手动给它添加一条呗。android:contentDescription="@string/value"

其他:

  • Set android:baselineAligned="false" on this element for better performance
    • 如果LinearLayout被用于嵌套的layout空间计算,它的android:baselineAligned属性应该设置成false,以加速layout计算
    • android:baselineAligned="false"
  • This LinearLayout layout or its RelativeLayout parent is useless;
    • 多余的Linearlayout或者RelativeLayout
    • 删除即可
  • This tag and its children can be replaced by one <TextView/> and a compound   drawable
    • 有时候我们可能会用image+textview组合,但其实image是没必要的,textview提供了一个属性来给它设置image
    • android:drawable="@drawable/resource"
  • Use a layout_height of 0dip instead of wrap_content for better   performance
    • 当在一个linearlayout布局中为一个控件设置weight属性时,这个组件会默认填充剩余空间
    • 去掉weight属性或者修改wrap_content为0dp
  • Buttons in button bars should be borderless
    • 原因未知
    • style="?android:attr/buttonBarButtonStyle"
 
posted @ 2015-04-24 18:11  HuijunZhang  阅读(475)  评论(1编辑  收藏  举报
中国