初学layout_weight疑问,求教!
来源:互联网 发布:学编程需要什么电脑 编辑:程序博客网 时间:2024/05/21 01:32
A.xml、B.xml两个布局文件,layout_weight设置不同但是运行后效果完全相同,但是实在不明白为什么layout_weight小的反而控件越大!
运行效果:
A.xml
B.xml
运行效果:
A.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="E" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="M" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="C" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
B.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="E" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="M" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="C" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
0 0
- 初学layout_weight疑问,求教!
- 关于android layout_weight的疑问
- !!!??页面怎么跳转?初学求教
- 初学php的疑问
- 初学的疑问
- C++初学疑问收集
- 初学java疑问
- oc初学疑问
- 初学Java的一些疑问
- 初学python闭包时的疑问
- 求教
- 求教!
- 求教
- 求教
- 求教!
- 求教
- 求教
- 求教
- C语言学习之指针
- Spark SQL中的broadcast join分析
- 06结构体
- js传参数——在jsrc后面以get方式传参
- Visual Studio 2017使用体验
- 初学layout_weight疑问,求教!
- phpstorm+xdebug+chrome helper配置php断点调试
- jtag访问arm内核寄存器
- unity之动画文件的设置与Apply Root Motion
- C语言中的运算符
- 基础架构-存储基础原理(1)
- 七种CSS方式让一个容器水平垂直居中
- iis图片防盗链 seo优化
- 传智播客韩忠康Mysql视频教程