安卓学习第二十一天:相对布局的使用,以及时间控件
来源:互联网 发布:人工智能技术推广方案 编辑:程序博客网 时间:2024/06/05 03:33
#1什么是相对布局
1,相对布局是另外一种控件摆放的方式
2,相对布局是通过指定当前控件与兄弟控件或者是父控件之间的相对位置,从而达到控制控件位置的目的
安卓布局嵌套得越多,这个程序的性能越差
默认放在左上角
android:layout_toRightof把当前控件的边缘对齐到特定id控件的右边缘,值是一个id
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"
android:layout_height="match_parent"android:paddingLeft="@dimen/activity_horizontal_margin"
tools:context=".MainActivity">
<TextView
android:id="@+id/tx"
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff0000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tx"
android:text="第二个TextView"
android:background="#00ff00"/>
</RelativeLayout>
效果图:
#2相对布局的最后一些属性
1android:layout_alignStart
2android:layout_alignEnd
3android:layout_alignParentStart
4android:layout_alignParentEnd
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/tx"
android:text="登录界面"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"/>
<EditText
android:id="@+id/edtx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="输入用户名"
android:layout_below="@id/tx"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"/>
<EditText
android:id="@+id/edtx2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="输入密码"
android:inputType="textPassword"
android:layout_below="@id/edtx"
android:layout_alignLeft="@id/edtx"
android:layout_alignRight="@id/edtx"
/>
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:layout_below="@id/edtx2"
android:layout_alignRight="@id/edtx2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="确定"
android:layout_below="@id/edtx2"
android:layout_toLeftOf="@id/cancel"/>
</RelativeLayout>
#3时间与日期
1,TimePicker与相应的监听器OntimeChangedListener
setIs24HourView设置使用24小时制
getCurrentHour()方法,获取当前时间
2,DataPicker
里面不能使用监听器
通过OnClickListener来监听时间改变
java中的月份是从第0月开始算的
3,AnalogClock模拟时钟
- 安卓学习第二十一天:相对布局的使用,以及时间控件
- 安卓实习第二十一天
- 安卓学习第十七天:相对布局的初步使用与换源学习
- 安卓相对布局
- 安卓相对布局
- 安卓相对布局
- 学习python的第二十一天
- 安卓相对布局的基本属性
- 安卓学习第一天:打造布局
- 相对布局的控件布局
- 第二十一天学习笔记
- 第二十一天学习记录
- Java学习第二十一天
- 安卓XML布局,相对布局的常用属性~
- 安卓之相对布局
- 安卓相对布局RelativeLayout
- 安卓中的相对布局
- 安卓 相对布局属性
- ubuntu update apt-get sourcelist
- 基础知识复习-十进制转二进制
- ndk 环境在mac,window,liunx上的的搭建
- Python编写简易木马程序
- eclipse 连接 sqlserver ping failed
- 安卓学习第二十一天:相对布局的使用,以及时间控件
- IOS关灯游戏的做法
- Android-eclipse下的自动补全
- canvas setShadowLayer()不起作用
- 内存管理-之内核内存管理-基于linux3.10
- 学习android之 Handler详细使用
- 运维神器-分分钟定位500错误!
- 2014年最新前端开发面试题集锦(题目列表+答案 完整版)
- XCode 模拟器路径