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

这个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的时候,需要设计登录界面的可以以此作为参考哦!

转载于:https://www.cnblogs.com/jiangu66/p/3238862.html

android登录界面相关推荐

  1. Android登录界面防劫持提醒处理

    Android登录界面防止被劫持,目前没有好的反劫持方法,只能提醒用户登陆界面被劫持,具体实施如下: 涉及到的工具类: import android.app.ActivityManager; impo ...

  2. android登录界面扁平,Android EditText实现扁平化的登录界面

    先来看看登录界面写完的效果图 2 监听editText,可以一键清空 3 checkBox的颜色统一 代码 下面,说说如何实现这个界面的,我将代码全部贴出来. xmlns:app="http ...

  3. Android 登录界面Demo源码

    2019独角兽企业重金招聘Python工程师标准>>> 布局分析:分成三个部分,该Activity是一个无标题的,设置无标题需要在setContentView之前设置,否则会报错, ...

  4. android登陆界面设计方案,011android初级篇之android登录界面的设计

    设计目标 密码账户的输入 输入账户时,自动显示匹配账户 没有帐号,显示官网超链接 登录框的自动提示功能参考一下链接中的AutoCompleteTextView的使用 布局文件 android:orie ...

  5. android登录界面居中,Android TextView前加图标垂直居中第一行(仿大众点评购买须知/提示语)...

    如上图,需求在每条提示语句前加一个小圆点,我刚看到需求就想到用 android:drawableLeft 来做,可做完发现:当TextView内容为单行的时候是没有问题的,多行的时候,添加的这个dra ...

  6. android 登录界面开源代码_【程序源代码】一个安卓查询类app制作的开源项目

    " 关键字:工作流 框架 springboot" 正文:一个学习安卓查询类app制作的开源项目.可以用来联系查询类app的编写. 01 - android studio最近势头好猛 ...

  7. android登录界面优化,Android 对登陆页面的美化(一)

    对登陆页面的美化(一) 对EditeText的美化 非常简单的实现浮动标签EditText: Android视图使用EditText之上,并提示EditText时填充文本. 核心代码不超过50行 先上 ...

  8. Android实现仿QQ登录界面背景动画效果

    登录QQ的时候,我们会看到在登录界面的背景不是静态的,而是一段动画效果,刚开始觉得蛮好奇的,现在我们也来实现一下这种效果,实现起来还是挺简单的. 实现步骤: 1.自定义CustomVideoView类 ...

  9. 怎么用Android做登录界面,利用Android怎么制作一个APP登录界面

    利用Android怎么制作一个APP登录界面 发布时间:2020-12-02 17:09:10 来源:亿速云 阅读:79 作者:Leah 这期内容当中小编将会给大家带来有关利用Android怎么制作一 ...

最新文章

  1. ashx+jQuery,一个轻量级的asp.net ajax解决方案
  2. 1.3.1 单隐层网络的数学实现
  3. python修改html的td_python3修改HTMLTestRunner,生成有截图的测试报告,并发送测试邮件(一)...
  4. linux 默认文件属性,linux系统下文件的默认权限以及隐藏属性的作用
  5. Tabs vs Spaces:如何在Google,Twitter,Mozilla和Pied Piper上编写Java
  6. error: default argument given for parameter 4
  7. 进一步理解CSS浮动与清除浮动
  8. Ubuntu14.04配置python接口,测试的小问题
  9. vscode写python爬虫_如何在vscode中调试python scrapy爬虫
  10. shell类型、添加PATH环境变量、.bashrc、.profile、/etc/profile、/etc/environment
  11. leetCode:35. 搜索插入位置
  12. 编程基本功:while/for循环中,如果有switch,注意break是中断的哪一层
  13. Intel HD Graphics
  14. 如何挑选微信第三方开发商
  15. 苹果证书导出p12文件
  16. HTML5在vivo手机适配问题
  17. 使用python进行基音周期的计算
  18. 查询自己电脑的IP地址
  19. 【学习笔记-时间序列预测】prophet-使用.3节日与特殊事件
  20. 大学四年级(yuan)

热门文章

  1. php基础知识点及留言板功能实现
  2. 云厂商之战,战至“边缘”
  3. 保留thinkvantage一键恢复功能的Linux与vista双系统安装
  4. 【资料分享】《建筑给水排水设计标准》(GB50015-2019)
  5. Android 12 预览版带给我们的1234
  6. 2020安恒杯元旦月赛-爆破鬼才-ZIP注释信息+CRC32爆破+outguess隐写爆破+生日字典
  7. Windows下完全卸载node.js并安装node.js的多版本管理工具nvm-windows
  8. 如何使用PowerPoint在幻灯片背景中添加DRAFT水印?
  9. 中国计算机报陈翔照片,陈翔六点半茅台真名 陈翔六点半茅台扮演者是谁(茅台照片、简介)...
  10. c语言1000的阶乘有几个零,1000的阶乘后面有多少个零?