android布局配置
代码:
res/layout/main.xml
<!--layout里面的xml命名可以改变,这里以main.xml进行说明 -->
<?xml version="1.0" encoding="utf-8"?>
<!--
layout_width - 宽。
fill_parent: 宽度跟着父元素走;
wrap_content: 宽度跟着本身的内容走;直接指定一个 px 值来设置宽
layout_height - 高。
fill_parent: 高度跟着父元素走;
wrap_content: 高度跟着本身的内容走;直接指定一个 px 值来设置高
-->
<!--
LinearLayout - 线形布局。
orientation - 容器内元素的排列方式。
vertical: 子元素们垂直排列;
horizontal: 子元素们水平排列
gravity - 内容的排列形式。常用的有 top, bottom, left, right, center 等,详见文档
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:gravity="right"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<!--
FrameLayout - 层叠式布局。以左上角为起点,将 FrameLayout 内的元素一层覆盖一层地显示
-->
<FrameLayout android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="FrameLayout">
</TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Frame Layout">
</TextView>
</FrameLayout>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/hello" />
<!--
TableLayout - 表格式布局。
TableRow - 表格内的行,行内每一个元素算作一列
collapseColumns - 设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
stretchColumns - 设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)的列的列索引,多个用“,”隔开
shrinkColumns - 设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开
-->
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:collapseColumns="1">
<TableRow android:id="@+id/TableRow01" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列1" />
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列2" />
<TextView android:layout_width="wrap_content"
android:layout_weight="1" android:layout_height="wrap_content"
android:text="行1列3" />
</TableRow>
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="行2列1" />
</TableRow>
</TableLayout>
<!--
AbsoluteLayout - 绝对定位布局。
layout_x - x 坐标。以左上角为顶点
layout_y - y 坐标。以左上角为顶点
-->
<AbsoluteLayout android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="AbsoluteLayout"
android:layout_x="100px"
android:layout_y="100px" />
</AbsoluteLayout>
<!--
RelativeLayout - 相对定位布局。
layout_centerInParent - 将当前元素放置到其容器内的水平方向和垂直方向的中央位置(类似的属性有 :layout_centerHorizontal, layout_alignParentLeft 等)
layout_marginLeft - 设置当前元素相对于其容器的左侧边缘的距离
layout_below - 放置当前元素到指定的元素的下面
layout_alignRight - 当前元素与指定的元素右对齐
-->
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_width="wrap_content" android:id="@+id/abc"
android:layout_height="wrap_content" android:text="centerInParent=true"
android:layout_centerInParent="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="marginLeft=20px"
android:layout_marginLeft="20px" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="xxx"
android:layout_below="@id/abc" android:layout_alignRight="@id/abc" />
</RelativeLayout>
</LinearLayout>
转载于:https://www.cnblogs.com/growing/archive/2010/11/17/1880134.html
android布局配置相关推荐
- Android Studio 配置OpenCV4.4.0 不用安装OpenCV Manager (泪崩居然用了礼拜天2天的时间居然还没配置成功,今天又看了下配置成功了)
Android Studio 配置OpenCV4.4.0 ,说来惭愧居然用户礼拜天2天的时间呢,期间遇到的问题大致有4个问题 这里我也总结出了最后在列举出来,(可能是新版和之前旧版本不一样的问题按照网 ...
- android开发4:Android布局管理器1(线性布局,相对布局RelativeLayout-案例)
控件类概述 View 可视化控件的基类 属性名称 对应方法 描述 android:background setBackgroundResource(int) 设置背景 android:clickabl ...
- Android布局加载慢,Android布局优化(四)X2C — 提升布局加载速度200%
系列文章 前言 在Android布局优化(一)从布局加载原理说起中我们说到了布局加载的两大性能瓶颈,通过IO操作将XML加载到内存中并进行解析和通过反射创建View.这里介绍一种避免运行时通过IO操作 ...
- Android 布局圆角方案总结
一.遇到的问题 最近在开发中会遇到Android布局切圆角的需求,大多数是对一个layout布局切下圆角.这里和图片切圆角有一些雷同的地方,可以相互借鉴,但是也不全一样.图片切圆角的一些总结和实践准备 ...
- Android布局原理与优化
Android布局原理与优化 目录: 绘制原理 CPU与GPU Android 图形系统的整体架构 RenderThread 硬件加速和软件绘制 invalidate软件绘制流程 invalidate ...
- 深入探索Android布局优化(上)
前言 成为一名优秀的Android开发,需要一份完备的知识体系,在这里,让我们一起成长为自己所想的那样~. Android的绘制优化其实可以分为两个部分,即布局(UI)优化和卡顿优化,而布局优化的核心 ...
- [安卓开发笔记一]Android开发配置opencv环境超详细教程
[安卓开发笔记一]Android开发配置opencv环境超详细教程 [更新于 2022年4月] 再次提醒,建议现在看到这篇文章的,仅仅把此文做一个流程参考,4年前android studio就使用cm ...
- Android布局动画之animateLayoutChanges与LayoutTransition
转载请注明出处(万分感谢!): http://blog.csdn.net/javazejian/article/details/52571779 出自[zejian的博客] 关联文章: 走进绚烂多彩的 ...
- android 布局回弹,Android仿IOS回弹效果 支持任何控件
本文实例为大家分享了Android仿IOS回弹效果的具体代码,供大家参考,具体内容如下 效果图: 导入依赖: dependencies { // ... compile 'me.everything: ...
- android 布局分析,关于Android应用程序界面五大布局的图文分析教程
对于安卓系统应用开发中界面的布局有五大类,分别是LinearLayout(线性布局).FrameLayout(单帧布局).AbsoluteLayout(绝对布局).TablelLayout(表格布局) ...
最新文章
- 五分钟带你入门TensorFlow
- Android中控件移动的实现
- sublime text3使用教程python_Sublime Text 编辑器配置 Python解释器简易教程
- 获取mongodb数据变更_支持mysql、MongoDB数据变更订阅/监听分发
- HDU-不容易系列之(3)—— LELE的RPG难题
- 如何查找SAP CRM通过中间件Middleware连接的远端ERP系统
- linux按日期备份mysql,在Linux、Windows上如何按日期逻辑备份数据库
- mysql in and in_完美解决mysql in条件语句只读取一条信息问题的2种方案
- android平台安全支付服务(msp)应用开发接口,Android接入支付宝和微信支付的方法...
- http 和 https 区别
- 开课吧课堂:什么是HashSet类
- python命令行参数 空格_Python 命令行参数
- MAC编译OpenJDK8:ld: library not found for -lstdc++(独家解决办法)
- 等比数列求和公式的推导
- 方差公式初三_方差|初中方差的计算公式
- POJ 3537.Crosses and Crosses(定义sg函数)
- 大学生python作业代做_代写COMP9021作业、代做Python编程语言作业、代写Python实验作业、代做program留学生作业...
- 台式机前面板插入耳机无反应无声音
- 正版 Windows 10安装教程
- 2018版 主流SDR设备横向比较