博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android基础知识复习——RelativeLayout布局属性、背景、半透明设置(XML设置)
阅读量:7117 次
发布时间:2019-06-28

本文共 2596 字,大约阅读时间需要 8 分钟。

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

 

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

  

 

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

[html] 
 
  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.           
  13.     <RelativeLayout  android:id="@+id/relativeLayout"   
  14.      android:layout_width="fill_parent"  
  15.      android:layout_height="wrap_content"  
  16.      android:layout_weight="2"   
  17.      android:padding="10px">                     //设置内间距  
  18.        
  19.   
  20.   /*颜色和不透明度 (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 */  
  21.   
  22.   
  23.      <TextView   
  24.         android:id="@+id/user"  
  25.         android:text="用户名: "  
  26.         android:layout_width="fill_parent"  
  27.         android:layout_height="wrap_content"  
  28.         android:textColor="#ffffffff" />        
  29.        
  30.      <EditText  android:id="@+id/username"  
  31.         android:layout_width="fill_parent"  
  32.         android:layout_height="wrap_content"   
  33.         android:layout_below="@id/user"      //在id为user的控件之下  
  34.         android:background="#88ffffff"/>     //设置不透明  
  35.           
  36.       <TextView   
  37.         android:id="@+id/key"  
  38.         android:layout_width="fill_parent"  
  39.         android:layout_height="wrap_content"   
  40.         android:text="密码:"  
  41.         android:layout_below="@id/username"  
  42.         android:textColor="#ffffffff" />  
  43.        
  44.      <EditText  android:id="@+id/keyword"  
  45.         android:layout_width="fill_parent"  
  46.         android:layout_height="wrap_content"   
  47.         android:layout_below="@id/key"  
  48.         android:background="#88ffffff"  
  49.         android:password="true"/>  
  50.        
  51.      <CheckBox   android:id="@+id/remember"   
  52.      android:layout_height="wrap_content"     
  53.      android:layout_width="wrap_content"   
  54.      android:text="记住密码"   
  55.      android:layout_below="@id/keyword"   
  56.      android:layout_alignLeft="@id/keyword"  
  57.      android:layout_marginLeft="15px"/>     //外间距  
  58.           
  59.     <CheckBox   android:id="@+id/autoin"   
  60.      android:layout_height="wrap_content"     
  61.      android:layout_width="wrap_content"   
  62.      android:text="自动登录"   
  63.      android:layout_below="@id/keyword"   
  64.      android:layout_alignRight="@id/keyword"    //与id为keyword的控件右对齐  
  65.      android:layout_marginRight="15px"/>  
  66.        
  67.      <Button android:id="@+id/enter"  
  68.      android:layout_height="wrap_content"     
  69.      android:layout_width="fill_parent"  
  70.      android:gravity="center_horizontal"    //内部文字位置  
  71.      android:text="登      录"  
  72.      android:layout_below="@id/autoin"  
  73.      android:layout_margin="10px"/>  
  74.        
  75.      </RelativeLayout>      
  76.       
  77. </LinearLayout>  

 

 

     本篇博客出自  ,转载请注明出处:

转载于:https://www.cnblogs.com/x_wukong/p/4496154.html

你可能感兴趣的文章
js跨域 jsop 使用
查看>>
Exchange服务器系统蓝屏及脱域后解决办法
查看>>
js处理url中文问题
查看>>
【翻译】在backtrack5上用Evilgrade工具15步**windows
查看>>
解析淘宝商城缘何更名“天猫”
查看>>
Struts2之checkboxlist 设置默认值和结果回显
查看>>
Spring 事务 状态信息的创建、回滚、清理、提交
查看>>
0927_C/C++笔试题_10:16道c语言面试例子【2】
查看>>
IIS Express 启用目录浏览
查看>>
当才华还配不上野心,就静下来学习
查看>>
编写高效的C++程序方法之使用对象池
查看>>
MFC子窗口和父窗口(SetParent,SetOwner)
查看>>
QT5(一):HelloWord
查看>>
Eclipse快捷键大全(同样适用基于Eclipse开发的IDE)
查看>>
JAVASE总复习
查看>>
windows应用迁移到linux下
查看>>
linux网卡研究
查看>>
考虑用静态工厂方法代替构造器
查看>>
常见排序算法:冒泡排序
查看>>
我的友情链接
查看>>