- 浏览: 710389 次
- 性别:
- 来自: 大连
文章分类
- 全部博客 (204)
- spring (6)
- hibernate (8)
- struts2 (8)
- J2SE (6)
- J2EE (4)
- DataBase (8)
- JQuery (4)
- AJAX (1)
- android (18)
- 软件工程 (3)
- MyEclipse (2)
- 生活 (4)
- QT (1)
- IT (3)
- java综合 (3)
- About PC (2)
- eclipse (3)
- linux (8)
- english (2)
- iPhone (1)
- struts2标签详解 (1)
- 数据库设计准则(第一、第二、第三范式说明) (1)
- DateUtils类提供日期的处理方法 (1)
- 网络 (2)
- 算法 (1)
- java (2)
- OS (1)
- DAO (1)
- WEB (1)
- WebServices (1)
- oracle (1)
- MYSQL (1)
- hadoop (4)
- spark (41)
- scala (8)
- jetty (1)
- news (2)
- maven (1)
- clover (1)
- zookeeper (1)
- hbase (2)
- 微信 (1)
- hive (4)
- zeppelin (2)
- tachyon (2)
最新评论
-
lixuanbin:
iteye已经快要tj了吧。。
iteye为什么不支持markdown? -
haorengoodman:
Tachyon 能在做数据分类吗?例如我有一坨hdfs文件,将 ...
tachyon与hdfs,以及spark整合 -
lee3836:
求源码,大牛
clover分布式任务调度系统 -
cfan37:
...
sparksql与hive整合 -
greemranqq:
9.9 送上,希望博客长久~。~
【【【【【#####>>>>>【关于我】【您·的·支·持·是·我·最·大·的·动·力】<<<<<#####】】】】】
一、概述
在开发中推荐尽量使用RelativeLayout可以增强其适应不同屏幕的灵活性。该布局根据widgets之间关系和widget与父容器之间的关系来确定布局。例如可以设置A在父容器的底部对齐,B在A的上方。
设置RelativeLayout的两大类主要的属性,如下:
1.widget与所在容器(Container)的关系
android:layout_alignParentTop
android:layout_alignParentBottom
android:layout_alignParentLeft
android:layout_centerHorizontal
......
2.widgets之间关系
android:layout_above
android:layout_below
android:layout_toLeft
android:layout_toRight
android:layout_alignTop
......
注意:widgets的出现先后顺序值得注意。被参照的widget必须保证已经出现了的。
二、实例分析
【效果图】
【代码要点】
main.xml
view plaincopy to clipboardprint?
1. <?xml version="1.0" encoding="utf-8"?>
2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3. android:orientation="vertical"
4. android:layout_width="fill_parent"
5. android:layout_height="wrap_content"
6. android:padding="5px"
7. >
8. <TextView
9. android:id="@+id/label"
10. android:layout_width="wrap_content"
11. android:layout_height="wrap_content"
12. android:text="URL:"
13. android:paddingTop="10px"
14. />
15. <EditText
16. android:id="@+id/entry"
17. android:layout_width="fill_parent"
18. android:layout_height="wrap_content"
19. android:layout_toRightOf="@id/label"
20. />
21. <Button
22. android:id="@+id/button1"
23. android:layout_width="wrap_content"
24. android:layout_height="wrap_content"
25. android:text="OK"
26. android:layout_below="@id/entry"
27. android:layout_alignRight="@id/entry"
28. />
29. <Button
30. android:id="@+id/button2"
31. android:layout_width="wrap_content"
32. android:layout_height="wrap_content"
33. android:text="Cancel"
34. android:layout_toLeftOf="@+id/button1"
35. android:layout_alignBottom="@+id/button1"
36. />
37. </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5px" > <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="URL:" android:paddingTop="10px" /> <EditText android:id="@+id/entry" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/label" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="OK" android:layout_below="@id/entry" android:layout_alignRight="@id/entry" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" android:layout_toLeftOf="@+id/button1" android:layout_alignBottom="@+id/button1" /> </RelativeLayout>
三、margin和padding的区别
在开发中推荐尽量使用RelativeLayout可以增强其适应不同屏幕的灵活性。该布局根据widgets之间关系和widget与父容器之间的关系来确定布局。例如可以设置A在父容器的底部对齐,B在A的上方。
设置RelativeLayout的两大类主要的属性,如下:
1.widget与所在容器(Container)的关系
android:layout_alignParentTop
android:layout_alignParentBottom
android:layout_alignParentLeft
android:layout_centerHorizontal
......
2.widgets之间关系
android:layout_above
android:layout_below
android:layout_toLeft
android:layout_toRight
android:layout_alignTop
......
注意:widgets的出现先后顺序值得注意。被参照的widget必须保证已经出现了的。
二、实例分析
【效果图】
【代码要点】
main.xml
view plaincopy to clipboardprint?
1. <?xml version="1.0" encoding="utf-8"?>
2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3. android:orientation="vertical"
4. android:layout_width="fill_parent"
5. android:layout_height="wrap_content"
6. android:padding="5px"
7. >
8. <TextView
9. android:id="@+id/label"
10. android:layout_width="wrap_content"
11. android:layout_height="wrap_content"
12. android:text="URL:"
13. android:paddingTop="10px"
14. />
15. <EditText
16. android:id="@+id/entry"
17. android:layout_width="fill_parent"
18. android:layout_height="wrap_content"
19. android:layout_toRightOf="@id/label"
20. />
21. <Button
22. android:id="@+id/button1"
23. android:layout_width="wrap_content"
24. android:layout_height="wrap_content"
25. android:text="OK"
26. android:layout_below="@id/entry"
27. android:layout_alignRight="@id/entry"
28. />
29. <Button
30. android:id="@+id/button2"
31. android:layout_width="wrap_content"
32. android:layout_height="wrap_content"
33. android:text="Cancel"
34. android:layout_toLeftOf="@+id/button1"
35. android:layout_alignBottom="@+id/button1"
36. />
37. </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5px" > <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="URL:" android:paddingTop="10px" /> <EditText android:id="@+id/entry" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/label" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="OK" android:layout_below="@id/entry" android:layout_alignRight="@id/entry" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Cancel" android:layout_toLeftOf="@+id/button1" android:layout_alignBottom="@+id/button1" /> </RelativeLayout>
三、margin和padding的区别
发表评论
-
解决Spinner不能在Tabhost中使用
2011-04-09 13:06 2550本想昨天晚上写这篇文章,但是我学校的网络真的太不给力了呢!竟然 ... -
Android屏幕分辨率详解(VGA、HVGA、QVGA、WVGA、WQVGA)
2011-03-31 20:44 1849这些术语都是指屏幕的分辨率。 VGA:Video Graph ... -
Android中Java代码和XML布局效率问题
2011-03-30 23:03 3305一般情况下对于Android程序布局我们往往使用XML文件来编 ... -
我服了android APIDemos中的带输入框的对话框
2011-03-28 20:59 2788我今天满怀信心的将AlertDialogSamples类看了很 ... -
Eclipse 安装 Google Android 插件
2011-03-27 15:33 1727已经在EclipseIDE编写android手机软件很长时间了 ... -
Android 小项目之--SQLite 使用法门 (附源码)
2011-03-26 13:47 2797每个应用程序都要使用数据,Android应用程序也不例外,An ... -
关于android的Menu理解
2011-03-26 13:23 1231任何一款软件都少不了 ... -
转载 国内Android 市场调查
2011-03-25 14:46 1432原文地址: http://www.cnbeta.com/art ... -
Android模拟器创建和管理sdcard image文件
2011-03-25 14:23 2458PS:以下操作都是在window系统 1:创建sdcard.i ... -
Android application context/activity context与内存泄露
2011-03-25 00:47 1736在android中context可以作很多操作,但是最主要的功 ... -
Android基础概念Context的作用
2011-03-25 00:42 1724Context字面意思上下文,位于framework pack ... -
Android布局java代码实现求助
2011-03-24 23:39 2381一般情况下对于Android程序布局我们往往使用XML文件来编 ... -
Laucher AndroidManifest.xml
2011-03-23 23:01 11301. permission 和 uses-permission ... -
windows下通过 DOS命令打开android模拟器实力
2011-03-23 22:29 1901步骤一:打开DOS窗口(cmd),并输入命令,进入文件夹: D ... -
Android预定义样式
2011-03-23 16:04 16561、字体大小 对于能够显示文字的控件(如TextView E ... -
通过适配器给AdapterView绑定数据
2011-03-23 15:39 4579使用AdapterView来绑定数据 AdapterView ... -
android的第一天学习
2011-03-10 22:19 12951:Android中TextView中的字体大小能设置吗? ...
相关推荐
Android布局入门,LinearLayout和RelativeLayout的理解和应用
Android 开发入门 对 RelativeLayout的基本属性的讲解和用法 ,更容易的帮你理解和使用
这个程序写了对相对布局和绝对布局的例子,帮助大家理解两者的使用和区别。
本文主要介绍Android clipChildren的属性,这里对clipChildren属性做了一个小例子,展示了效果图和实例代码,方便大家观看理解
4)实现对Android布局LinearLayout,FrameLayout,RelativeLayout,TableLayout的自定义封装; 2015-4-8 说明:上面计划的是对Android的控件和布局进行自定义封装,在阅读API和源码的过程中发现,对他们在Android...
以下代码在Scrollview里面放了一个RelativeLayout、并且是设置为Android:layout_height=”match_parent”填充全屏的和RelativeLayout里面放置了一个TextView背景设为了一张图片、按照代码理解、图片应该是居于屏幕的...
ConstraintLayout有效的解决了多层嵌套复杂布局的问题,加快渲染速度,有点类似与RelativeLayout和LinearLayout的集合,但是远比RelativeLayout和LinearLayout强大。 本文建议的是通过手写代码的方式来构造布局,等...
我在开发项目模块中使用的测试平台,主要用来测试一下组件的属性,这个平台中综合运用了象 FrameLayout relativelayout linearlayout 这些组件,在一个main.xml中同时用到,并明显的区别了它们的使用效果。...
一个应用的布局是丰富的,有TextView,ImageView,Button等,这些子View的外层还有ViewGroup,如RelativeLayout,LinearLayout。作为一个开发者,我们会思考,当点击一个按钮,Android系统是怎样确定我点的就是按钮...
经典教程 Flex 布局教程:语法篇 Flex 布局教程:实例篇 flex布局游戏 理解 flex布局实现需要至少两层...不像安卓里有那么多的定义好了布局规则的ViewGroup,比如RelativeLayout,Linearlayout,以及Listview,GridVi
但是,由于这是一个简易版的音乐播放器,所播放的音乐只有一首,且被写死,但,操作却十分简单,方便理解! 这是代码的主要设计: 音乐主要存放在这一个文件中: 下面就来介绍各部分代码: activity—main。xml: ...
我们对Android应用程序运行原理及布局文件可谓有了比较深刻的认识和理解,并且用“HelloWorld!”程序来实践证明了。在继续深入Android开发之旅之前,有必要解决前两篇中没有介绍的遗留问题:View的几种布局显示方法...
直接把自定义的这个View代码放上来,有注释应该很好理解: 首先是布局: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+...
本文主要结合自己的理解分别对使用LinearLayout和RelativeLayout两种方式实现居中做了总结,希望对大家有所帮助。
我理解的安卓中MVC思想是利用Holder进行编程,展示布局,提供视图,将视图和数据进行绑定起来,在很多App中我们能见到广告条,广告条这里我们可以使用FramLayout进行填充,然后利用MVC的思想将提供的布局添加到...
2.4.1 ListActivity 2.4.2XML布局 2.4.3 把数据绑定到列表 2.4.4 Loader 2.5 理解活动 2.5.1 声明活动 2.5.2了解活动的生命周期 2.5.3 了解任务和返回堆栈 2.5.4 处理配置更改 2.6 防止应用程序无响应(ANR) 2.6.1...
二、实训任务 1、Activity的相关知识 简单理解Activity 代表一个用户所能看到的屏幕,Activity 主要是处理一个应用的整体性工作。Activity是最基本的Android 应用程序组件,应用程序中,一个活动通常就是一个单独的...