在网上在到一个登录界面感觉挺不错的,给大家分享一下~先看效果图:

这个Demo除了按钮、小猫和Logo是图片素材之外,其余的UI都是通过代码实现的。

一、背景

背景蓝色渐变,是通过一个xml文件来设置的。代码如下:

background_login.xml

[html] 
view plain
copy

 

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android">
  3. <gradient
  4. android:startColor="#FFACDAE5"
  5. android:endColor="#FF72CAE1"
  6. android:angle="45"
  7. />
  8. </shape>

startColor是渐变开始的颜色值,endColor是渐变结束的颜色值,angle是渐变的角度。其中#FFACDAE5中,FF是Alpha值,AC是RGB的R值,DA是RGB的G值,E5是RGB的B值,每个值在00~FF取值,即透明度、红、绿、蓝有0~255的分值,像要设置具体的颜色,可以在PS上的取色器上查看设置。

二、圆角白框

效果图上面的并不是白框,其实框是白色的,只是设置了透明值,也是靠一个xml文件实现的。

background_login_div.xml

[html] 
view plain
copy

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android">
  3. <solid android:color="#55FFFFFF" />
  4. <!-- 设置圆角
  5. 注意: bottomRightRadius是左下角而不是右下角  bottomLeftRadius右下角-->
  6. <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
  7. android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>
  8. </shape>

三、界面的布局

界面的布局挺简单的,就直接贴代码啦~

login.xml

[html] 
view plain
copy

 

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:orientation="vertical"
  5. android:layout_width="fill_parent"
  6. android:layout_height="fill_parent"
  7. android:background="@drawable/background_login">
  8. <!-- padding 内边距   layout_margin 外边距
  9. android:layout_alignParentTop 布局的位置是否处于顶部 -->
  10. <RelativeLayout
  11. android:id="@+id/login_div"
  12. android:layout_width="fill_parent"
  13. android:layout_height="wrap_content"
  14. android:padding="15dip"
  15. android:layout_margin="15dip"
  16. android:background="@drawable/background_login_div_bg" >
  17. <!-- 账号 -->
  18. <TextView
  19. android:id="@+id/login_user_input"
  20. android:layout_width="wrap_content"
  21. android:layout_height="wrap_content"
  22. android:layout_alignParentTop="true"
  23. android:layout_marginTop="5dp"
  24. android:text="@string/login_label_username"
  25. style="@style/normalText"/>
  26. <EditText
  27. android:id="@+id/username_edit"
  28. android:layout_width="fill_parent"
  29. android:layout_height="wrap_content"
  30. android:hint="@string/login_username_hint"
  31. android:layout_below="@id/login_user_input"
  32. android:singleLine="true"
  33. android:inputType="text"/>
  34. <!-- 密码 text -->
  35. <TextView
  36. android:id="@+id/login_password_input"
  37. android:layout_width="wrap_content"
  38. android:layout_height="wrap_content"
  39. android:layout_below="@id/username_edit"
  40. android:layout_marginTop="3dp"
  41. android:text="@string/login_label_password"
  42. style="@style/normalText"/>
  43. <EditText
  44. android:id="@+id/password_edit"
  45. android:layout_width="fill_parent"
  46. android:layout_height="wrap_content"
  47. android:layout_below="@id/login_password_input"
  48. android:password="true"
  49. android:singleLine="true"
  50. android:inputType="textPassword" />
  51. <!-- 登录button -->
  52. <Button
  53. android:id="@+id/signin_button"
  54. android:layout_width="wrap_content"
  55. android:layout_height="wrap_content"
  56. android:layout_below="@id/password_edit"
  57. android:layout_alignRight="@id/password_edit"
  58. android:text="@string/login_label_signin"
  59. android:background="@drawable/blue_button" />
  60. </RelativeLayout>
  61. <RelativeLayout
  62. android:layout_width="fill_parent"
  63. android:layout_height="wrap_content" >
  64. <TextView  android:id="@+id/register_link"
  65. android:text="@string/login_register_link"
  66. android:layout_width="wrap_content"
  67. android:layout_height="wrap_content"
  68. android:layout_marginLeft="15dp"
  69. android:textColor="#888"
  70. android:textColorLink="#FF0066CC" />
  71. <ImageView android:id="@+id/miniTwitter_logo"
  72. android:src="@drawable/cat"
  73. android:layout_width="wrap_content"
  74. android:layout_height="wrap_content"
  75. android:layout_alignParentRight="true"
  76. android:layout_alignParentBottom="true"
  77. android:layout_marginRight="25dp"
  78. android:layout_marginLeft="10dp"
  79. android:layout_marginBottom="25dp" />
  80. <ImageView android:src="@drawable/logo"
  81. android:layout_width="wrap_content"
  82. android:layout_height="wrap_content"
  83. android:layout_toLeftOf="@id/miniTwitter_logo"
  84. android:layout_alignBottom="@id/miniTwitter_logo"
  85. android:paddingBottom="8dp"/>
  86. </RelativeLayout>
  87. </LinearLayout>

四、Java源文件

Java源文件比较简单,只是实例化Activity,去掉标题栏。

[java] 
view plain
copy

 

  1. package com.mytwitter.acitivity;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.view.Window;
  5. public class LoginActivity extends Activity {
  6. @Override
  7. public void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. requestWindowFeature(Window.FEATURE_NO_TITLE);
  10. setContentView(R.layout.login);
  11. }
  12. }

在开发APP的时候,需要设计登录界面的可以以此作为参考哦!

android登录界面的更多相关文章

  1. Android 登录界面调用输入法时让界面自动上移,使输入法不会遮挡到主界面(Activity)

    先贴上效果图:   <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:andr ...

  2. Android登录界面实现

    花了一些时间实现了一个还算可以等登陆界面,主要是对这两天工作的一个总结:自定义按钮.编辑框.布局.全屏等. 效果如下: 获取代码:点这里

  3. Android 登录界面与首页的设计

    全屏效果 //取消标题,取消状态栏 this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(Wind ...

  4. android 登录界面

    http://blog.csdn.net/jiabinjlu/article/details/6920967 http://blog.csdn.net/myserverthepeople/articl ...

  5. android内部培训视频_第五节(1)_OA实战之登录界面

    第五节(1):OA实战之登录界面  一.登录界面布局 1.背景图片 2.文本框 3.checkbox 4.按钮 暂未实现点击切换图片效果 <RelativeLayout xmlns:androi ...

  6. android 案例二 登录界面

    效果图: 运行图:   总结: 编写这个简单的用户登录界面,主要用到了以下的知识:   java基础中的IO流的操作 用以读取.显示用户的信息 Android布局 线性布局和相对布局 数据的存储选在包 ...

  7. Android之QQ登录界面

    首先过程中碰到的几个问题: 1.对 EditText 进行自定义背景 2.运行时自动 EditText 自动获得焦点 3.在获得焦点时即清空 hint ,而不是输入后清空 4.清空按钮的出现时机(在得 ...

  8. Android 仿 窗帘效果 和 登录界面拖动效果 (Scroller类的应用) 附 2个DEMO及源码

    在android学习中,动作交互是软件中重要的一部分,其中的Scroller就是提供了拖动效果的类,在网上,比如说一些Launcher实现滑屏都可以通过这个类去实现.下面要说的就是上次Scroller ...

  9. Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy

    原文:Android菜鸟的成长笔记(3)--给QQ登录界面说So Easy 上一篇:Android菜鸟的成长笔记(2)--第一个Android应用 我们前面已经做了第一个Android应用程序,虽然有 ...

随机推荐

  1. windbg检查常用命令

    1.dt  视图结构内容 dt + 结构名   要么 dt + 结构名 + 住址 kd> dt _object_header nt!_OBJECT_HEADER +0x000 PointerCo ...

  2. 《javascript高级编程》读书笔记(两)javascript基本概念

    第三章:基本概念 ECMAScript那里5种简单数据类型(也称基本数据类型):Undefined\Null\Boolean\Number\String,另一种复杂数据类型--Object,Objec ...

  3. HDU 4819 Mosaic D区段树

    连接:pid=4819">http://acm.hdu.edu.cn/showproblem.php?pid=4819 意:给出一个800×800下面的矩阵.每次更新一个点的值为以这个 ...

  4. MTK MOTA升级步骤

    MOTA的前提下有其自己的server,MTK我在已经完成,可以MTK应用,然后移动到它自己的server向上. 1.打开ProjectConfig.mk中间MTK_SYSTEM_UPDATE_SUP ...

  5. mod_wsgi + pymssql通路SQL Server座

    靠pymssql通路SQL Server时刻,直接地python没有问题的执行.靠mod_wsgi和Apache当部署.所有请求被发现hang然后数据库查询. 通过google查到了答案,感谢goog ...

  6. Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 3

    DDL Setup Steps SQL> grant execute on utl_file to ggs; Grant succeeded. Create GLOBALS file [orac ...

  7. hdu 4965 Fast Matrix Calculation(矩阵高速幂)

    题目链接.hdu 4965 Fast Matrix Calculation 题目大意:给定两个矩阵A,B,分别为N*K和K*N. 矩阵C = A*B 矩阵M=CN∗N 将矩阵M中的全部元素取模6,得到 ...

  8. POJ 3934 Queue(DP)

    Queue Description Linda is a teacher in ACM kindergarten. She is in charge of n kids. Because the di ...

  9. 谈到一些传统的企业网站SEO问题领域

    在网络营销中的时间越长,有时候,企业网站还是有一些传统做法不解.也许,这是它的思想的局限.比如,我最近来到了一个新的工作环境中发现,虽然公司是专业从事传统渠道已经很不错了,但对于网络营销渠道还有改进的 ...

  10. SharePoint 2013 中将 HTML文件转换为母版页

    原文:SharePoint 2013 中将 HTML文件转换为母版页 SharePoint 2013提供了很多新功能,下面我们看看将Html页面,转换为母版页的功能.这个功能更加方便设计人员设计母版页 ...