zoukankan      html  css  js  c++  java
  • android基础知识复习——RelativeLayout布局属性、背景、半透明设置(XML设置)

    转自: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.           
    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>  

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

  • 相关阅读:
    Openjudge-计算概论(A)-单词翻转
    Openjudge-计算概论(A)-字符串排序
    Openjudge-计算概论(A)-过滤多余的空格
    Openjudge-计算概论(A)-单词倒排
    Openjudge-计算概论(A)-统计字符数
    Openjudge-计算概论(A)-奇数单增序列
    碎碎的光阴(湖北荆门一考生)
    Openjudge-计算概论(A)-找和为K的两个元素
    php延迟加载的示例
    php排序测试
  • 原文地址:https://www.cnblogs.com/x_wukong/p/4496154.html
Copyright © 2011-2022 走看看