t;>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3"></Button>
</LinearLayout>
<!--蓝色框 -->
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="0">
</Button>
<Button
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=".">
</Button>
</LinearLayout>
</LinearLayout>
<!--红色框,=号-->
<LinearLayout android:orientation="vertical"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="=">
</Button>
</LinearLayout>
</LinearLayout>
(2)相对布局
相对布局是最灵活的一种布局方式,可以相对父容器和相对与其他控件进行布局。
主要参数有:
1. 是否对齐父容器的语法格式为true/false:
例如:android:layout_alignParentLeft = “true”
2. 为于给定ID控件不同方位的语法格式:
例如:android:layout_above="@id/btn1"
@id/btn1 控件的ID必须是事前已经定义好的
android:layout_alignParentLeft 该控件是否对齐父容器的左端
android:layout_alignParentRight 该控件是否齐其父容器的右端
android:layout_alignParentTop 该控件是否对齐父容器的顶部
android:layout_alignParentBottom 该控件是否对齐父容器的底部
android:layout_centerInParent 该控件是否相对于父容器居中
android:layout_toLeftOf 该控件位于给定ID控件的左方
android:layout_toRightOf 该控件位于给定ID控件的右方
android:layout_above |