Android studio学习笔记3

RelativeLayout常见属性

  • 相对于父元素给控件布局

    android:layout_centerHrizontal 若为ture水平居中

    android:layout_centerVertical  若为ture垂直居中

    android:layout_centerInparent 相对于父元素完全居中

    android:layout_alignParentBottom 位于父元素的下边缘

    android:layout_alignParentLeft 位于父元素的左边缘

    android:layout_alignParentRight 位于父元素的右边缘

    android:layout_alignParentTop 位于父元素的上边缘

    android:layout_alignWithParentIfMissing 如果对应的兄弟元素找不到的话就以父元素做参照物

  • 属性值必须为id的引用名“@id/id-name”

    android:layout_below 位于元素的下方

    android:layout_above 位于元素的的上方

    android:layout_toLeftOf 位于元素的左边

    android:layout_toRightOf 位于元素的右边

    android:layout_alignTop 该元素的上边缘和某元素的的上边缘对齐

    android:layout_alignLeft 该元素的左边缘和某元素的的左边缘对齐

    android:layout_alignBottom 该元素的下边缘和某元素的的下边缘对齐

    android:layout_alignRight 该元素的右边缘和某元素的的右边缘对齐

  • 给属性赋予像素值

    android:layout_marginBottom 底边缘的距离

    android:layout_marginLeft 左边缘的距离

    android:layout_marginRight 右边缘的距离

    android:layout_marginTop 上边缘的距离

    代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    //设置了为线性布局
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"      //对局为垂直对齐
android:background="#00aff0"       //设置背景色,用取色器
tools:context=".MainActivity"> <RelativeLayout              //采用相对布局
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"> <Button
android:textColor="@android:color/white"
android:id="@+id/bt_ms_account"
android:background="@drawable/bg_blue"
android:layout_alignParentBottom="true"
android:text="MS账号"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> <Button
android:id="@+id/bt_sk_account"
android:textColor="@android:color/white"
android:layout_marginBottom="20dp"
android:layout_above="@id/bt_ms_account"
android:background="@drawable/bg_blue"
android:text="skype用户"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> <ImageView
android:id="@+id/im_count"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:layout_above="@id/bt_ms_account"
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</RelativeLayout> <RelativeLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:layout_marginTop="20dp"
android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"> <ImageView
android:layout_weight="1"
android:src="@drawable/windows"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/mail"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/skype"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/xbox"
android:layout_width="0dp"
android:layout_height="22dp" />
<ImageView
android:layout_weight="1"
android:src="@drawable/cloud"
android:layout_width="0dp"
android:layout_height="22dp" /> </LinearLayout>
<TextView
android:id="@+id/tv_count"
android:textColor="@android:color/white"
android:background="#00a3de"
android:padding="15dp"
android:layout_alignParentBottom="true"
android:textSize="20dp"
android:text="创建账号"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> <TextView
android:id="@+id/tv_login"
android:textColor="@android:color/white"
android:gravity="center"
android:layout_marginBottom="25dp"
android:layout_above="@id/tv_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"/>
</RelativeLayout> </LinearLayout>

Android studio学习笔记3的更多相关文章

  1. Android Studio 学习笔记(一)环境搭建、文件目录等相关说明

    Android Studio 学习笔记(一)环境搭建.文件目录等相关说明 引入 对APP开发而言,Android和iOS是两大主流开发平台,其中区别在于 Android用java语言,用Android ...

  2. Android Studio学习笔记

    转:http://stormzhang.com/devtools/2014/11/25/android-studio-tutorial1 背景 相信大家对Android Studio已经不陌生了,An ...

  3. Android Studio 学习笔记(1)

    最近从Eclipse转到Android Studio IDE,很多东西需要学习,本文是个记录. 项目结构 在Anroid Studio 中,一个Project 包括多个Module,每个Module下 ...

  4. Android Studio 学习笔记1.1 创建自己的第一个安卓项目并且打包APK

      自从上一次安装完安卓开发工具Android Studio后抽时间看视屏尝试编写自己的第一个安卓项目约两周的时间 每天下班后会花上1~2小时的时间去学习 目前的成果如下:次元宅的我.apk 嘛 总而 ...

  5. Android Studio 学习笔记(二):布局简介和xmlns说明

    初学Android Studio,是在b站看的教程视频,这里的笔记也是以其为基础的,个人强烈安利: [天哥]Android开发视频教程最新版 Android Studio开发 Android 布局简介 ...

  6. Android Studio 学习笔记(四):Adapter和RecyclerView说明

    在现版本中,滚动控件有多种,而相比于ListView,GridView,RecyclerView的用途更广,因此将前两者作为Adapter适配器的引入,再对RecyclerView进行简单讲解. MV ...

  7. Android Studio 学习笔记(三):简单控件及实例

    控件.组件.插件概念区分 说到控件,就不得不区分一些概念. 控件(Control):编程中用到的部件 组件(Component):软件的组成部分 插件(plugin): 应用程序中已经预留接口的组件 ...

  8. Android Studio 学习笔记(五):WebView 简单说明

    Android中一个用于网页显示的控件,实际上,也可以看做一个功能最小化的浏览器,看起来类似于在微信中打开网页链接的页面.WebView主要用于在app应用中方便地访问远程网页或本地html资源.同时 ...

  9. Git for Android Studio 学习笔记

    http://learngitbranching.js.org/ 一个特别好的git学习教程 创建一个project,然后导入github

  10. Android自动化学习笔记:编写MonkeyRunner脚本的几种方式

    ---------------------------------------------------------------------------------------------------- ...

随机推荐

  1. 安装node.js与webpack创建vue2项目

    本文为博主原创,转载请注明出处: 1.安装node.js 下载地址:http://nodejs.cn/download/ (可查看历史版本) node.js 中文网:http://nodejs.cn/ ...

  2. Javaweb后端学习笔记

    C/S结构与B/S结构: 1.C/S(Client/Server)结构:适用于个人娱乐市场[QQ等] (1).优点:安全性高.且有效降低服务器压力: (2).不足:增加服务成本.更新较繁琐: 2.B/ ...

  3. Python实现k-近邻算法案例学习

    一.介绍 你好,我是悦创. 博客首发:https://bornforthis.cn/column/Machine-learning/informal-essay/01.html 本文是由给私教学员 c ...

  4. mysql 复制数据

    1.表存在 insert into table_name(key1,key2) select key3,key4 from table_name_2; 2.表不存在 create table test ...

  5. ArcGIS工具 - 批量删除空图层

    为了减少数据的冗余,我们经常需将数据库中的空图层(没有任何记录的要素类或表)删除,删除数据本来是一个很简单的操作,但如果数据量大,则需通过程序来处理.例如,删除成百上千个标准分幅DLG数据库中等高线数 ...

  6. 将 Timer 对象化

    Timer这玩意儿很常用,却又很烦人.烦人之处有四: 1.         如果将其设到HWND上,则 a)         必须手工维护Timer的ID,小心翼翼地保证这些ID不重复,可能有人(比如 ...

  7. A. Greatest Convex【Codeforces Round #842 (Div. 2)】

    A. Greatest Convex You are given an integer \(k\). Find the largest integer \(x\), where \(1≤x<k\ ...

  8. C 语言初学者必备开发工具——Dev-Cpp [ 图文安装教程 ]

    前言 C 语言是一门功能强大的专业化编程语言,深受专业程序员和业余编程爱好者的喜爱,同时 C 语言也是当今最流行的嵌入式开发语言.大多数嵌入式项目的开发都是用 C 语言来编写的. 既然 C 语言这么厉 ...

  9. 鸿蒙系统应用开发之基于API6的蓝牙开发

    写在前面 由题意得,我今天讲的是基于鸿蒙系统的兼容JS的类Web开发范式的软件应用开发之蓝牙开发,它是基于API6的,至于为什么是基于API6,请你花几分钟看一下我之前写的这个系列教程的第四篇&quo ...

  10. 音频编辑服务UI SDK接入指导及常见问题

    华为 HMS Core 音频编辑服务(Audio Editor Kit)是华为帮助全球开发者快速构建各类应用音频能力的服务,汇聚了华为在音乐.语音等相关音频领域的先进技术.音频编辑服务为开发者们提供音 ...