Android课程---课下练习(表格、线性和相对布局)
1.表格布局
练习代码:
<?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:stretchColumns="4,2">
<TableRow>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="To:"
android:layout_span="4"/>
</TableRow>
<TableRow>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Subject:"
android:layout_span="4"/>
</TableRow>
<TableRow>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Message:"
android:layout_span="4"
android:paddingBottom="340dp"/>
</TableRow>
<TableRow>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_weight="1"/>
</TableRow> </TableLayout>
效果图:

2.线性布局
练习代码:
<?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">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="To:"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject:"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Message:"
android:paddingBottom="340dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_weight="1"/>
</LinearLayout> </LinearLayout>
效果图:

3.相对布局
练习代码:
<?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"> <EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="To:"
android:id="@+id/to"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject:"
android:layout_below="@+id/to"
android:id="@+id/su"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Message:"
android:layout_below="@+id/su"
android:paddingBottom="350dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
android:layout_alignParentBottom="true"
android:id="@+id/re"
android:layout_marginLeft="90dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_toRightOf="@+id/re" /> </RelativeLayout>
效果图:

ps:是不是发现最后一张效果图与前面2张不一样了,其实前面那2张才是正确的,那你就该问了,为什么最后一个不一样啊?事实是我试了好多办法,练习了好久,遗憾的是最后用相对布局方法还是没能做出来,只能放上我做的这张图了
Android课程---课下练习(表格、线性和相对布局)的更多相关文章
- android从放弃到坚持放弃第二课(下)
续第二课( 下) 续第二课 下 活动的生命周期 返回栈 活动状态 活动的生存期 体验活动的生命周期 活动被回收怎么办 活动的启动模式 standard singleTop singleTask sin ...
- 【Xamarin开发 Android 系列 7】 Android 结构基础(下)
原文:[Xamarin开发 Android 系列 7] Android 结构基础(下) *******前期我们不打算进行太深入的东西,省的吓跑刚进门的,感觉门槛高,so,我们一开始就是跑马灯一样,向前 ...
- android第二课:运行你的应用
如果你按照前面课程创建了 Android 项目,它包含了可以立即运行的 "Hello World"源代码文件. 由两该条件来决定如何运行你的应用:你是否拥有运行着 Android ...
- 20175234 数据库MySQL(课下作业)
20175234 数据库MySQL(课下作业) 内容: 1.下载附件中的world.sql.zip, 参考http://www.cnblogs.com/rocedu/p/6371315.html#SE ...
- 课下测试补交(ch01、ch02、ch07)
课下测试补交(ch01.ch02.ch07) 课下测试ch01 1.Amdahl定律说明,我们对系统的某个部分做出重大改进,可以显著获得一个系统的加速比.(B) A . 正确 B . 错误 解析:课本 ...
- # 课下测试补交(ch01)20155337
课下测试补交(ch01) 1.Amdahl定律说明,我们对系统的某个部分做出重大改进,可以显著获得一个系统的加速比.(B) A .正确 B .错误 解析:Amdahl定律,该定律的主要思想是,当我们对 ...
- 2017-2018-1 20155327 《信息安全系统设计基础》课堂测试&课下作业
2017-2018-1 20155327 <信息安全系统设计基础>课堂测试&课下作业 学习使用stat(1),并用C语言实现 提交学习stat(1)的截图 man -k ,grep ...
- 课下测试CH01补交
课下测试CH01补交 ( 单选题 | 1 分) Amdahl定律说明,我们对系统的某个部分做出重大改进,可以显著获得一个系统的加速比. A . 正确 B . 错误 正确答案: B 你的答案: 未作答 ...
- Android课程设计第一天Android Studio安装
注意:课程设计只为完成任务,不做细节描述~ 学校有一个Android的课设,所以顺便把Android Studio安装了上去. 实际上安装过程并不复杂,只有几个地方需要注意~ 安装包可以去http:/ ...
随机推荐
- json返回数据库的时间格式为/Date(1477294037000)/,怎样在前台进行格式化转换
方法一: 原理是取中间的数,再转换成js的Date类型 function ChangeDateFormat(val) { if (val != null) { var date = new Date( ...
- CDN(内容分发网络)是什么?
尽可能避开互联网上有可能影响数据传输速度和稳定性的瓶颈和环节,使内容传输的更快.更稳定.其目的是使用户可就近取得所需内容,解决Internet网络拥挤的状况,提高用户访问网站的响应速度. 解决CDN缓 ...
- CSS3设置多张背景图片
background-image:url("1.jpg"),url("2.jpg"),url("3.jpg");background-rep ...
- Javascript参考手册
---------------------------------------------------------------------------------------------------- ...
- 使用maven 如何生成源代码的jar包
http://hw1287789687.iteye.com/blog/1943157
- 【SAP BO】BOE 4.1版本新特性
为了更好地向用户推广BusinessObjects BI 4.1版本的新特性,SAP公司宣布将在2012年中旬推出针对BusinessObjects BI 4.0的功能补丁程序(Feature Pac ...
- 使用oracle11g_instant_client来解决在不安装oracle客户端的情况下连接服务端
一.下载instantclient_11_2,可去oracle官网进行下载. 二.解压缩下载的instantclient_11_2,将instantclient_11_2目录拖放到C:\Program ...
- #来自codeforces round 363
具体情况是这样的:同样的程序,在我自己的电脑上跑出来是正确的结果,而提交到CF的评测机后对于相同的输入数据,结果居然不一样了!反复检查后未发现任何问题.目前怀疑可能与memset有关,因为在一步步修改 ...
- unity update 和fixedudpate
但是Update会在每次渲 染新的一帧时被调用. 而FixedUpdate会在每个固定的时间间隔被调用,
- Activiti工作流学习(二)流程实例、执行对象、任务
一.前言 前面说明了基本的流程部署.定义,启动流程实例等基本操作,下面我们继续来学习流程实例.执行对象.任务. 二.流程实例.执行对象说明 整个Activiti的生命周期经过了如下的几个步骤: 1.流 ...