layout_weight的意义在于原有面积+剩下的部分 例如添加代码如下 android:id="@+id/btn_a" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/btn_a" android:layout_weight="1" /> android:id="@+id/btn_b" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="2" android:text="@string/btn_b"/> android:id="@+id/btn_c" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/btn_c" android:layout_weight="2" /> 这时在显示时就会按照1:2:2的面积显示 但是这是首先设置的height为自适应 假如把height设置为fill_parent就会出现如下情况 android游戏开发课程<wbr>layout_weight的意义 出现这种状况是因为三个Button的layout_height全部设为fill_parent 这其实与weight的原理有关,本来整个屏幕可以认为是1,但3个就需要3 可想而知剩下为1-3=-2 button1就变成了1(本来的fill_parent)+-2*1/5(剩下的)=3/5 button2 1-2/5 3 1-2/5 相当于3:1:1 也就是如图情况

更多相关文章

  1. android高级应用课程
  2. 关于接口类型的10篇课程推荐
  3. C++引用的意义与引用的本质
  4. 如何用C语言计算矩形的周长和面积?(附代码)
  5. C语言怎么计算矩形的面积和周长
  6. c语言如何计算圆面积和周长
  7. C语言中%d,%s,%x,%f,%.100的意义
  8. c语言如何求三角形的面积
  9. c语言实现输入圆的半径计算圆的面积

随机推荐

  1. Android人與iPhone人大不同
  2. android下歌曲名称乱码的解决办法
  3. 详细讲解如何安装原生安卓电子市场(androi
  4. android ”三分屏”视频播放器
  5. android 开发布局之AbsoluteLayout
  6. Android Training - 网络操作(3) - 解析X
  7. Android市场动态呈现 最新数据抢先看
  8. 八款开源Android游戏引擎(转)
  9. Android(安卓)进程保活--1像素保活
  10. Android Binder机制浅析