- 浏览: 186117 次
- 性别:
- 来自: 湖南
文章分类
- 全部博客 (52)
- 一般 (2)
- java (2)
- 硬件的学习,软件的呼应 (1)
- 硬件知识 (2)
- 数组和队列基础的研究 (1)
- 初步了解文件保存与对io刘深刻的理解 (1)
- io与文件 (1)
- android五大布局 (1)
- Java与mySQL之间的概述 (0)
- mySQL命令口的概述 (1)
- android.多线程.生命周期 (1)
- java.android.the development of voice (1)
- android ConcurrentModificationException 异常 (1)
- linux (1)
- linux shell (1)
- linux 操作系统 进程 c++ 解析 (1)
- C# 画板 实现和通信解析 (0)
- java Mina TCP/IP UDP/IP (1)
- java Mina 通信源码的解析 (1)
- java中数据结构二分查法 (1)
- java中数据结构Bitmap查找相等元素 (1)
- java Bitmap 数据结构 (1)
- 二进制 低级语言 高级语言 (1)
- C# 画板 问题解析 (1)
- C# UDP TCP (1)
- C# 聊天室 过程 (1)
- java Mina 解析 (1)
- web html 语言的标示解析 (1)
- html jsp 乱码解决 (1)
- web java lib jsp的javamail (1)
- JAVA Spring STRUCTS Hibernate (0)
- Java Spring Struts Hibernate (0)
- TCP UDP (1)
- Java Web Spring Struts Hibernate (1)
- LabSQL (1)
- labview labSQL mySQL (1)
- Windows DLL 操作系统 (1)
- R语言 学习包 (1)
- B树 算法 数据结构 (1)
- labview TCP/IP 波形图 (1)
- C++ KMP 数据结构 算法 (1)
- C++ KMP 数据结构 算法 理论 (1)
- 数据结构 B+ B* (1)
- B树 数据结构 结构体 思路 (1)
- B树 高度 性能 思路 (1)
- 顺序Gauss消除法 矩阵 数值分析 C++ (1)
- C++ 排序 数据结构 算法 理论 (1)
- Java 重绘 继承 对象 Wallpaper (0)
- Java 对象 继承 重绘 多态 Wallpaper (1)
- Java Tomcat web 错误解析 (1)
- Java 队列 堆解析 (1)
- Java JDK 优先队列 PriorityQueue (0)
- Java JDK 优先队列 PriorityQueue (1)
- Android JNI C语言 Ubuntu Linux ADB工具 动态链接库so (0)
- Android JNI C语言 Ubuntu Linux ADB工具 动态链接库so (1)
- 研发 核心技术 产品 技术 市场 (0)
最新评论
-
q114687576:
http://www.blue-zero.com/Chat/ ...
C# 聊天室的框架设计实现源码 -
chinesejie:
你用了byte 数组, 其实 空间最多节省 4倍
Bitmap算法查找相等元素源码 -
luozhong915127:
JuliaAilse 写道那个桢布局的。覆盖后可以在需要时再显 ...
android 界面布局 -
这不是我:
很好,很有帮助
R语言中的机器学习包 -
luozhong915127:
什么意思,踩别人连个意见都不给。
优先队列与堆的解析
1.线性布局(LinearLayout)
线性布局的形式可以分为两种,第一种横向线性布局第二种纵向线性布局,总而言之都是以线性的形式一个个排列出来的,纯线性布局的缺点是很不方便修改控件的显示位置,所以开发中经常会以线性布局与相对布局嵌套的形式设置布局。设置线性布局为水平方向
android:orientation="horizontal"
设置线性布局为垂直方向
android:orientation="vertical"
设置正比例分配控件范围
设置控件显示位置,这里为水平居中
android:gravity="center_horizontal"
在xml中我使用了LinearLayout 嵌套的方式 配置了2个线性布局一个水平显示一个垂直显示。
<?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="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" android:gravity="center_horizontal" android:layout_weight="2" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/joy" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="luozhong" android:background="#FF0000" android:textColor="#000000" android:textSize="18dip" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="水平方向" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="luozhong" android:background="#FF0000" android:textColor="#000000" android:textSize="18dip" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="垂直方向" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="luozhong" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/image" /> </LinearLayout> </LinearLayout>
2.帧布局(FrameLayout)
原理是在控件中绘制任何一个控件都可以被后绘制的控件覆盖,最后绘制的控件会盖住之前的控件。如图所示界面中先绘制的ImageView 然后在绘制的TextView和EditView 所以后者就覆盖在了前者上面。
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/g" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Luozhong" android:background="#FF0000" android:textColor="#000000" android:textSize="18dip" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/image" android:layout_gravity="bottom" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="快乐生活每一天喔" android:layout_gravity="bottom" /> </FrameLayout>
3.相对布局(RelativeLayout)
相对布局是android布局中最为强大的,首先它可以设置的属性是最多了,其次它可以做的事情也是最多的。android手机屏幕的分辨率五花八门所以为了考虑屏幕自适应的情况所以在开发中建议大家都去使用相对布局它的坐标取值范围都是相对的所以使用它来做自适应屏幕是正确的。
设置距父元素右对齐
android:layout_alignParentRight="true"
设置该控件在id为re_edit_0控件的下方
android:layout_below="@id/re_edit_0"
设置该控件在id为re_image_0控件的左边
android:layout_toLeftOf="@id/re_iamge_0"
设置当前控件与id为name控件的上方对齐
android:layout_alignTop="@id/name"
设置偏移的像素值
android:layout_marginRight="30dip"
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <EditText android:id="@+id/re_edit_0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="luozhong" android:layout_alignParentRight="true" /> <ImageView android:id="@+id/re_iamge_0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/re_edit_0" android:layout_alignParentRight="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="努力学习" android:textColor="#000000" android:textSize="18dip" android:layout_toLeftOf="@id/re_iamge_0" /> <EditText android:id="@+id/re_edit_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="luozhong" android:layout_alignParentBottom="true" /> <ImageView android:id="@+id/re_iamge_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/re_edit_1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#FF0000" android:text="努力工作" android:textColor="#000000" android:textSize="18dip" android:layout_toRightOf="@id/re_iamge_1" android:layout_above="@id/re_edit_1" /> </RelativeLayout>
4.绝对布局(AbsoluteLayout)
使用绝对布局可以设置任意控件的 在屏幕中 X Y 坐标点,和帧布局一样后绘制的控件会覆盖住之前绘制的控件,笔者不建议大家使用绝对布局还是那句话因为android的手机分辨率五花八门所以使用绝对布局的话在其它分辨率的手机上就无法正常的显示了。
android:layout_x="50dip" android:layout_y="30dip" <?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/f" android:layout_x="100dip" android:layout_y="50dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="当前坐标点 x = 100dip y = 50 dip" android:background="#FFFFFF" android:textColor="#FF0000" android:textSize="18dip" android:layout_x="50dip" android:layout_y="30dip" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/h" android:layout_x="50dip" android:layout_y="300dip" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="当前坐标点 x = 50dip y = 300 dip" android:background="#FFFFFF" android:textColor="#FF0000" android:textSize="18dip" android:layout_x="30dip" android:layout_y="280dip" /> </AbsoluteLayout>
5.表格布局(TableLayout)
在表格布局中可以设置TableRow 可以设置 表格中每一行显示的内容 以及位置 ,可以设置显示的缩进,对齐的方式
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/g" android:layout_gravity="center" /> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="姓名" android:gravity="left" /> <TextView android:text="电话" android:gravity="right"/> </TableRow> <View android:layout_height="2dip" android:background="#FFFFFF" /> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="luozhong" android:gravity="left" /> <TextView android:text="15810463139" android:gravity="right"/> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="妹妹" android:gravity="left" /> <TextView android:text="15810463139" android:gravity="right"/> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="先生" android:gravity="left" /> <TextView android:text="15810463139" android:gravity="right"/> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip" > <TextView android:text="姓名" android:gravity="left" /> <TextView android:text="性别" android:gravity="right"/> </TableRow> <View android:layout_height="2dip" android:background="#FFFFFF" /> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip" > <TextView android:text="luozhong" android:gravity="left" /> <TextView android:text="男" android:gravity="right"/> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="美美" android:gravity="left" /> <TextView android:text="女" android:gravity="right"/> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:padding="10dip"> <TextView android:text="先生" android:gravity="left" /> <TextView android:text="男" android:gravity="right"/> </TableRow> </TableLayout>
评论
能够了,你收到文字和图片定义不同的协议就可以解决该问题啦
相关推荐
android界面布局详解
android界面布局,介绍android界面的各个布局样式
有关于android界面布局的详解,对初学者应该很有帮助
android界面布局设计
可以参考对应的文章有描述。 地址:http://blog.csdn.net/gufengcangying/article/details/24883831
android界面布局相关教程以及工具,自动转换
设计android界面布局实用教案.pptx
设计android界面布局学习教案.pptx
设计android界面布局PPT学习教案.pptx
详细介绍了Android 的界面布局 及UI设计,pdf格式。
Android 开发在每个布局中加上水印效果。需求:在每个布局中加上水印效果
android线性、相对、表格、绝对、标签、层布局描述,使用桌面组件Widget布局,在屏幕上实现文字显示,设置字体,下拉列表,自动实现输入文本等功能。经过调试。
android 开发入门很好的实例,我就是按照这个步骤进行的开发。
GUI可视化设计器——DroidDraw Dr oidDraw是基于Java Swing的Android界面设计器,可以通过它生成复杂的Android Layout Xml文件。
最新最实用的android菜单界面布局,不下会后悔的
Android界面布局的目的是为了合理利用屏幕空间,并能适配多种屏幕。我们可以利用布局来设计各个控件的位置排布。 Android提供了6种基本布局类:帧布局(FrameLayout)、线性布局(LinearLayout)、绝对布局...
Android开发登陆界面布局