1.线性布局:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:orientation="vertical" >    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="按钮1" />    <Button  android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right|center_vertical" android:text="按钮2" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮3" />    <LinearLayout  android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮1" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="按钮2" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:text="按钮3" />    </LinearLayout></LinearLayout>2.相对布局:<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="进攻" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:text="左勾拳" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:text="右勾拳" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:text="逃跑" />    <Button  android:id="@+id/btn_bisha" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="大绝招" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/btn_bisha" android:layout_alignTop="@id/btn_bisha" android:text="左" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/btn_bisha" android:layout_centerHorizontal="true" android:text="上" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/btn_bisha" android:layout_alignBaseline="@id/btn_bisha" android:text="右" />    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/btn_bisha" android:layout_centerHorizontal="true" android:text="下" /></RelativeLayout>3.帧布局:<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >    <Button  android:layout_width="300px" android:layout_height="300px" android:layout_gravity="center" android:text="最底部" />    <Button  android:layout_width="150px" android:layout_height="150px" android:layout_gravity="center" android:text="中间" />    <Button  android:layout_width="50px" android:layout_height="50px" android:layout_gravity="center" android:text="顶部" /></FrameLayout>4.表格布局:<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:shrinkColumns="0" android:collapseColumns="0" >    <TableRow android:layout_height="wrap_content" >        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一行, 0列" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一行, 1列" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一行, 2列" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一行, 3列" />    </TableRow>    <TableRow android:layout_height="wrap_content" >        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二行, 0列" />        <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2" android:layout_span="2" android:text="第二行, 1列" />    </TableRow></TableLayout>5.绝对布局:<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >    <Button  android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="1dp" android:layout_y="253dp" android:text="按钮" /></AbsoluteLayout>6.dp与px:<?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:layout_width="160px" android:layout_height="wrap_content" android:text="单位是px" android:textSize="18px" />    <Button  android:layout_width="160dp" android:layout_height="wrap_content" android:text="单位是sp" android:textSize="18sp" /></LinearLayout>

更多相关文章

  1. android - 头中尾布局
  2. android之【TableLayout布局】
  3. android 在配置文件中指定上级activity
  4. Android(安卓)五大布局之(一) 线性布局和相对布局
  5. 如何使用android中的搜索功能
  6. Android(安卓)笔记一:线性布局
  7. 如何在Android和iOS设备上录制游戏?
  8. Android属性gravity与layout_gravity的区别
  9. Android(安卓)线性布局详解

随机推荐

  1. 前端 UI 样式:01Vue.js组件样式属性 scope
  2. 算法中的“哨兵”到底是啥?怎么用?
  3. EXCEL将各个Sheet工作表另存为新工作簿
  4. 数组计算操作
  5. 浅谈移动前端开发和、Web 前端开发的区别
  6. 【阿里云镜像】使用VM虚拟机安装OpenWRT
  7. 数组功能操作
  8. 人工智能数据准备、AI数据准备
  9. 初见数组(操作数组元素值)
  10. c#开发office办公自动化随笔