android__常见布局

来源:互联网 发布:红旗linux系统 编辑:程序博客网 时间:2024/06/05 02:27

RelativeLayout
相布局:可以设置位置,通过layout_marginLeft、layout_marginTop等
这里写图片描述

AbsoluteLayout
绝对布局:可以任意放置,通过layout_x 和layout_y
这里写图片描述

FrameLayout
帧布局:一层一层的悬浮在界面上,如暂停按钮
这里写图片描述

LinearLayout
线性布局:自上而下或自左向右,控件没有对齐设置
这里写图片描述

TableLayout
表格布局:一行一行的
这里写图片描述

<TableRow         android:layout_width="match_parent"        android:layout_height="wrap_content"          >        <!--            layout_weight:表示权重,权重一样大的平分屏幕宽度             gravity:文本局中        -->        <TextView             android:layout_weight="1"            android:gravity="center"            android:layout_width="0dip"            android:layout_height="wrap_content"            android:text="哈哈"            />        <TextView             android:layout_weight="1"            android:gravity="center"            android:layout_width="0dip"            android:layout_height="wrap_content"            android:text="嘎嘎"                        />    </TableRow>

集合布局:
这里写图片描述

<?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" >    <Button        android:id="@+id/button2"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" />    <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" />    <Button        android:id="@+id/button3"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" /></LinearLayout>
0 0
原创粉丝点击