美文网首页
LinearLayout 对比 RelativeLayout

LinearLayout 对比 RelativeLayout

作者: 小二二二7 | 来源:发表于2019-08-27 14:47 被阅读0次

    性能对比:LinearLayout比RelativeLayout要好
    因为RelativeLayout会测量两次,而默认情况下(没有设置weight),LinearLayout 只测量一次
    为什么RelativeLayout会测量两次,首先,RelativeLayout的子view是基于相互依赖的关系,而这个依赖可能和子view的顺序无关,在确定子view的位置时,需要先给每个子view排序,又因为RelativeLayout支持横向和纵向的依赖,所以横向和纵向都要分别进行一次测量

    相关文章

      网友评论

          本文标题:LinearLayout 对比 RelativeLayout

          本文链接:https://www.haomeiwen.com/subject/ildeectx.html