转自:http://blog.csdn.net/fansongy/article/details/6817968

复习布局与XML,写了一个空的登录界面。XML的注释我写在当行的后面了。程序运行图:

主函数没有改动,不贴了。背景图片名为:background.jpg 。看看main.xml吧。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:background="@drawable/background"         //设置背景
  7. >
  8. <LinearLayout android:id="@+id/empty"             //占位用的layout
  9. android:layout_width="fill_parent"
  10. android:layout_height="wrap_content"
  11. android:layout_weight ="1"></LinearLayout>   //设置占总权重的比例
  12. <RelativeLayout  android:id="@+id/relativeLayout"
  13. android:layout_width="fill_parent"
  14. android:layout_height="wrap_content"
  15. android:layout_weight="2"
  16. android:padding="10px">                     //设置内间距
  17. /*颜色和不透明度 (alpha) 值以十六进制表示法表示。任何一种颜色的值范围都是 0 到 255(00 到 ff)。对于 alpha,00 表示完全透明,ff 表示完全不透明。表达式顺序是“aabbggrr”,其中“aa=alpha”(00 到 ff);“bb=blue”(00 到 ff);“gg=green”(00 到 ff);“rr=red”(00 到 ff)。例如,如果您希望对某叠加层应用不透明度为 50% 的蓝色,则应指定以下值:7fff0000 */
  18. <TextView
  19. android:id="@+id/user"
  20. android:text="用户名: "
  21. android:layout_width="fill_parent"
  22. android:layout_height="wrap_content"
  23. android:textColor="#ffffffff" />
  24. <EditText  android:id="@+id/username"
  25. android:layout_width="fill_parent"
  26. android:layout_height="wrap_content"
  27. android:layout_below="@id/user"      //在id为user的控件之下
  28. android:background="#88ffffff"/>     //设置不透明
  29. <TextView
  30. android:id="@+id/key"
  31. android:layout_width="fill_parent"
  32. android:layout_height="wrap_content"
  33. android:text="密码:"
  34. android:layout_below="@id/username"
  35. android:textColor="#ffffffff" />
  36. <EditText  android:id="@+id/keyword"
  37. android:layout_width="fill_parent"
  38. android:layout_height="wrap_content"
  39. android:layout_below="@id/key"
  40. android:background="#88ffffff"
  41. android:password="true"/>
  42. <CheckBox   android:id="@+id/remember"
  43. android:layout_height="wrap_content"
  44. android:layout_width="wrap_content"
  45. android:text="记住密码"
  46. android:layout_below="@id/keyword"
  47. android:layout_alignLeft="@id/keyword"
  48. android:layout_marginLeft="15px"/>     //外间距
  49. <CheckBox   android:id="@+id/autoin"
  50. android:layout_height="wrap_content"
  51. android:layout_width="wrap_content"
  52. android:text="自动登录"
  53. android:layout_below="@id/keyword"
  54. android:layout_alignRight="@id/keyword"    //与id为keyword的控件右对齐
  55. android:layout_marginRight="15px"/>
  56. <Button android:id="@+id/enter"
  57. android:layout_height="wrap_content"
  58. android:layout_width="fill_parent"
  59. android:gravity="center_horizontal"    //内部文字位置
  60. android:text="登      录"
  61. android:layout_below="@id/autoin"
  62. android:layout_margin="10px"/>
  63. </RelativeLayout>
  64. </LinearLayout>

本篇博客出自  阿修罗道,转载请注明出处:http://blog.csdn.net/fansongy/article/details/6817968

android基础知识复习——RelativeLayout布局属性、背景、半透明设置(XML设置)的更多相关文章

  1. Android基础知识复习之打开照相机拍照并获取照片

    对于我来说,做一件事情: 首先要理清我的思路,我要打开照相机,我能想到的是:在Android中我要打开系统应用,肯定需要一个隐式意图,那就要查询Android照相机的源码,查看并找到意图过滤器的书写方 ...

  2. 【Xamarin开发 Android 系列 4】 Android 基础知识

    原文:[Xamarin开发 Android 系列 4] Android 基础知识 什么是Android? Android一词的本义指“机器人”,同时也是Google于2007年11月5日宣布的基于Li ...

  3. android:layout_alignleft layout_toleftof区别,详解RelativeLayout布局属性

    转载请注明博客地址. 最近看博客看到有关于RelativeLayout布局的解释,有的解释很多是错误的.因此有必要对每一个常见的布局属性进行描述.以下解释全部都是逐行进行测试的. 首先把常用的布局分组 ...

  4. WPF基础知识、界面布局及控件Binding(转)

    WPF是和WinForm对应的,而其核心是数据驱动事件,在开发中显示的是UI界面和逻辑关系相分离的一种开放语言.UI界面是在XAML语言环境下开发人员可以进行一些自主设计的前台界面,逻辑关系还是基于c ...

  5. WPF基础知识、界面布局及控件Binding

    WPF是和WinForm对应的,而其核心是数据驱动事件,在开发中显示的是UI界面和逻辑关系相分离的一种开放语言.UI界面是在XAML语言环境下开发人员可以进行一些自主设计的前台界面,逻辑关系还是基于c ...

  6. Android基础_3 Activity相对布局

    相对布局要比前面讲的线性布局和表格布局要灵活一些,所以平常用得也是比较多的.相对布局控件的位置是与其周围控件的位置相关的,从名字可以看出来,这些位置都是相对的,确定出了其中一个控件的位置就可以确定另一 ...

  7. Android 如何把一个 RelativeLayout或ImageView背景设为透明

    在项目中,需要把RelativeLayout 和  ImageView背景设置为透明,怎么实现呢?这里主要通过代码,请参阅以下关键代码: public ImageView imgDetail; pri ...

  8. Android基础知识巩固:关于PendingIntent和广播

    平时使用广播的场合比较多,但细节的东西,看过了也没有总结,以至于某些场合有小问题,还是要把原理和属性搞清楚才能运用自如. 其实也是自己比较懒,先看别人的blog,有个概念再去官网看英文的能好理解一些. ...

  9. Android基础知识-1

    1.Android的Activity任务栈 在Android的系统中,在APP运行时每个APP都会默认有一个任务栈,任务栈的名称以APP的包名命名.任务栈是一中先进后出的结构,APP中每一个调用的Ac ...

随机推荐

  1. 2015多校第8场 HDU 5382 GCD?LCM! 数论公式推导

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5382 题意:函数lcm(a,b):求两整数a,b的最小公倍数:函数gcd(a,b):求两整数a,b的最 ...

  2. REST,Web 服务,REST-ful 服务

    介绍 REpresentational State Transfer (REST) 是一种架构原则,其中将 web 服务视为资源,可以由其 URL 唯一标识.RESTful Web 服务的关键特点是明 ...

  3. php中mvc新建页面

    PHP配置: <?phpclass appointmentController extends Controller{public function __construct(){parent:: ...

  4. 【python】时间戳、字典列表排序

    记录一下昨天学到的知识: 一.文件相关 文件追加:f = open("fname","a")    文件不存在时创建 二.时间戳相关 http://www.jb ...

  5. 听justjavac大神live前端的入门与进阶小笔记

    代码规范 代码强壮,调试代码 少用变量,多用常量 少用for循环,why循环,多用函数式, 不要直接去使用框架 刷题 提高编程思维 用js去做c语音的问题 阅读别人代码,去看别人的代码 a+b> ...

  6. linux服务器上如何显示工作路径

    1. 修改PS环境变量 [root@linux-node01 ~]# vi /etc/bashrc [ "$PS1" = "\\s-\\v\\\$ " ] &a ...

  7. 解决Tomcat因Redis加载慢而启动失败的问题

    StartTomcat.py import subprocess as t import time, os, requests, sys WEB_IP = '127.0.0.1:8080' # WEB ...

  8. 启动WAMPSERVER出现计算机中丢失 MSVCR110.dll

    最近电脑因为系统损坏无法启动,不得已重装系统,也让PHP程序员雷雪松下决心坚决的抛弃XP系统.这样一来跟上时代的步伐,二来也为Win7的市场占有率和消灭IE7以下浏览器做点贡献.,作为一个PHP程序员 ...

  9. css div图片上下左右居中

    <style type="text/css"> div{border:1px solid #ccc;height:500pc;width:500px;text-alig ...

  10. 2017CCPC 杭州 J. Master of GCD【差分标记/线段树/GCD】

    给你一个n个初始元素都为1的序列和m个询问q. 询问格式为:l r x(x为2or3) 最后求1~n所有数的GCD GCD:把每个数分别分解质因数,再把各数中的全部公有质因数提取出来连乘,所得的积就是 ...