Android布局之ReativeLayout
如果你的程序中出现了多个LinearLayout嵌套,就应该考虑使用相对布局了。相对局部顾名思义一个控件的位置相对于其他控件或者容器的位置。使用很简单 直接上示例:
<?xml version="1.0" encoding="utf-8"?>
<!-- 相对布局 一个控件相对于另一个控件或者容器的位置。 -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/describe_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textColor="#556055"
/>
<!-- 这个TextView相对于上一个TextView 在 它的下方所以设置属性为layout_below-->
<TextView
android:id="@+id/username_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/username"
android:textColor="#556055"
android:layout_below="@id/describe_view"
/>
<EditText
android:id="@+id/username_edit"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_marginTop="4dp"
android:layout_toRightOf="@id/username_view"
android:layout_below="@id/describe_view"
/>
<TextView
android:id="@+id/sex_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/sex"
android:textColor="#556055"
android:layout_below="@id/describe_view"
android:layout_toRightOf="@id/username_edit"
/>
<RadioGroup
android:id="@+id/sex_radiogroup"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/sex_view"
android:layout_below="@id/describe_view"
>
<!--第一个RadioButton -->
<RadioButton
android:id="@+id/male_radiobutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"
/>
<!--第二个RadioButton -->
<RadioButton
android:id="@+id/woman_radiobutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"
/>
</RadioGroup>
<TextView
android:id="@+id/age_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="25dp"
android:text="@string/age"
android:textColor="#556055"
android:layout_below="@id/username_view"
/>
<EditText
android:id="@+id/brithday_edit"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_marginTop="4dp"
android:hint="@string/selectdate"
android:textSize="13sp"
android:gravity="center"
android:editable="false"
android:layout_toRightOf="@id/age_view"
android:layout_below="@id/username_edit"
/>
<TextView
android:id="@+id/education_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="25dp"
android:text="@string/education"
android:textColor="#556055"
android:layout_below="@id/sex_view"
android:layout_toRightOf="@id/brithday_edit"
/>
<!-- 下拉列表控件 -->
<Spinner
android:id="@+id/edu_spinner"
android:layout_width="108dp"
android:layout_height="38dp"
android:layout_below="@id/sex_radiogroup"
android:layout_toRightOf="@id/education_view"
/>
<TextView
android:id="@+id/interest_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="25dp"
android:text="@string/interest"
android:textColor="#556055"
android:layout_below="@id/age_view"
/>
<!-- 复选框控件 -->
<CheckBox
android:id="@+id/car_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/car"
android:textColor="#566156"
android:layout_toRightOf="@id/interest_view"
android:layout_below="@id/brithday_edit"
/>
<CheckBox
android:id="@+id/sing_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="11dp"
android:text="@string/sing"
android:textColor="#566156"
android:layout_toRightOf="@id/car_check"
android:layout_below="@id/brithday_edit"
/>
<CheckBox
android:id="@+id/movie_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="11dp"
android:text="@string/movie"
android:textColor="#566156"
android:layout_toRightOf="@id/sing_check"
android:layout_below="@id/brithday_edit"
/>
<Button
android:id="@+id/submit_button"
android:layout_width="100dp"
android:layout_height="40dp"
android:text="@string/submit"
android:gravity="center"
android:layout_below="@id/movie_check"
android:layout_marginLeft="210dp"
android:layout_marginTop="15dp"
/>
</RelativeLayout>
- RelativeLayout.rar (244.1 KB)
- 下载次数: 0
发表评论
-
资料上传备份
2012-07-02 07:28 0对付对付对付对付 -
Android-sharedUserId数据权限
2012-05-02 10:16 1409Android-sharedUserId数据权限 An ... -
Android Service学习之本地服务
2012-04-18 10:28 800转: Android Service学习之本地服务 htt ... -
match_parent和fill_parent的区别 .
2012-02-18 11:49 1783match_parent和fill_parent的区别 有 ... -
Android中SQLiteOpenHelper类的onUpgrade方法的作用
2012-02-09 11:50 4562Android中SQLiteOpenHelper类的onUpg ... -
Android启动各种系统服务线程
2012-02-09 10:59 1898Android启动各种系统服务 ... -
android
2012-02-08 09:22 0Android数据库内容变化的监听 首先介绍内容监 ... -
在线升级Android应用程序的思路
2012-02-07 11:34 822在线升级Android应用程序的思路 http://www. ... -
Android数据库内容变化的监听
2012-02-07 11:31 5992Android数据库内容变化的监听 首先介绍内容监 ... -
android中的数据库操作
2012-02-07 10:50 1410android中的数据库操作 ... -
SQLiteOpenHelper类与自动升级数据库
2012-02-07 10:31 2240SQLiteOpenHelper类与自动升级数据库 S ... -
SQLite外键的实现
2012-02-07 10:30 1661SQLite外键的实现 SQLite现在的版本还不支持 ... -
Android到处都在使用的回调分析
2011-12-21 15:53 3503Android到处都在使用的回调分析 ... -
android中LayoutInflater的使用
2011-12-21 11:35 1899android中LayoutInflater的使用 ... -
SIM卡满处理流程分析
2011-12-19 15:15 1844SIM卡满处理流程分析 //框架层分析 // SMSD ... -
短信发送状态报告流程分析
2011-12-19 15:07 2351短信发送状态报告流程分析 //应用层分析: //Sms ... -
Android平台 短信接送流程剖析(含编码)
2011-12-16 15:29 3197Android平台 短信接送流程剖析(含编码) ... -
修改语言环境方法
2011-12-16 15:20 996修改语言环境方法 private void se ... -
Android平台 短信发送流程剖析(含编码)
2011-12-12 17:12 4263Android平台 短信发送流程剖析(含编码) 本文对A ... -
Android 应用程序签名
2011-11-27 11:34 1603Android 应用程序签名 转:http://www ...
相关推荐
android 布局生成图片,封装工具类 ,简单实用,viewgroup生成图片分享微信,快速转化
android 布局 android 布局android 布局android 布局
Android布局控件之RelativeLayout详解
Android布局显示模板加载,空,错误等状态
设计Android应用程序的界面经常用到xml格式的布局文件。一个布局文件的作用是描述了: - 界面包含哪些控件(也叫组件或视图;示例有按钮,下拉框); - 控件之间的位置关系; - 如何显示界面的整体外观和各个...
LinearLayout 线性布局 控制组件 横向 或者 纵向 排列 RelativeLayout 相对布局 子组件的位置总是相对兄弟组件,父容器来决定的 FrameLayout 帧布局、框架布局 创建一个空白区域, 一个区域成为一帧 TableLayout 表格...
常用的几种安卓布局历程,eclipse平台,可以直接导入
android不同的布局资源介绍,包括LinearLayout、RelativeLayout等
android 布局的详细分析 android 布局的详细分析 android 布局的详细分析
安卓布局讲解。各个控件的讲解,及其属性。代码展示。 1 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:orientation="vertical" 4 android:layout_width="fill_parent" 5...
Android布局高级.doc
android 布局别名的应用
Android 相对布局实例 ,RalateLayout
android布局属性,在平时开发中不断总结的,很值得参考
android布局属性详解.全面讲解各种技术。值得学习。
首先,在res下面新建一个文件夹drawable,在drawable下面新建三个xml文件:shape_corner_down.xml、shape_corner_up.xml和shape_corner.xml,分别是下面两个角是圆角边框,上面两个角是圆角...solid android:color=#0
Android xml布局文件工具
对初次学习Android布局的人有很大的帮助更好的了解属性
android最全的布局属性总结,各种Layout如linearlayout ,relativeLayout,frameLayout,各种widget属性说明
Android流式布局简单实现,通过继承ViewGroup,重写OnLayout方法,实现标签的流式布局