zoukankan      html  css  js  c++  java
  • LinearLayout布局之weight

    weight的正确使用方法:

    先设置 android:layout_width="0dp" 或者 android:layout_height="0dp"

    然后再去调配权重,而此时的weight也非常好理解: weight就是比重。

    weight的错误使用方法:

    android:layout_width="match_parent"

     android:layout_width="wrap_content" 

    两种情况下该如何设置weight. 因为这样设置根本就是错误的用法.

    下面是来自SDK的一句话:In order to improve the layout efficiency when you specify the weight, you should change the width of theEditText to be zero (0dp). Setting the width to zero improves layout performance because using "wrap_content"as the width requires the system to calculate a width that is ultimately irrelevant because the weight value requires another width calculation to fill the remaining space.它的大致意思就是说: 我们如果在某个方向上使用了weight ,那么我们必须在对应的方向上将width设置为0dp. 它告诉了我们设置为0dp是因为使用weight,系统是采用了另外一套计算占用空间大小的算法的.(the weight value requires another width calculation to fill the remaining space.)

  • 相关阅读:
    easyui datagrid 前后台代码
    JVM
    序列化
    Android UI设计
    多线程
    泛型
    字符串
    B+树:MySql数据库索引是如何实现的
    大数据判存算法:海量数据中快速判断某个数据是否存在
    陌生单词
  • 原文地址:https://www.cnblogs.com/xushihai/p/4554097.html
Copyright © 2011-2022 走看看