android游戏开发课程layout_…
16lz
2021-12-04
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就会出现如下情况 layout_weight的意义" title="android游戏开发课程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 也就是如图情况
更多相关文章
- android手动拖动滚动条快速滑动
- 元素可指定如下常用属性
- Android(安卓)android:gravity属性介绍及效果图
- [转]Android(安卓)源代码结构
- android 带文字的ImageButton
- centos下安装adb环境
- 解决Could not find manifest-merger.jar问题
- Android下修改ImageButton样式
- android手动拖动滚动条快速滑动