android登录界面
在网上在到一个登录界面感觉挺不错的,给大家分享一下~先看效果图:
这个Demo除了按钮、小猫和Logo是图片素材之外,其余的UI都是通过代码实现的。
一、背景
背景蓝色渐变,是通过一个xml文件来设置的。代码如下:
background_login.xml
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="#FFACDAE5"
- android:endColor="#FF72CAE1"
- android:angle="45"
- />
- </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
- <?xml version="1.0" encoding="UTF-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="#55FFFFFF" />
- <!-- 设置圆角
- 注意: bottomRightRadius是左下角而不是右下角 bottomLeftRadius右下角-->
- <corners android:topLeftRadius="10dp" android:topRightRadius="10dp"
- android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp"/>
- </shape>
三、界面的布局
界面的布局挺简单的,就直接贴代码啦~
login.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/background_login">
- <!-- padding 内边距 layout_margin 外边距
- android:layout_alignParentTop 布局的位置是否处于顶部 -->
- <RelativeLayout
- android:id="@+id/login_div"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="15dip"
- android:layout_margin="15dip"
- android:background="@drawable/background_login_div_bg" >
- <!-- 账号 -->
- <TextView
- android:id="@+id/login_user_input"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginTop="5dp"
- android:text="@string/login_label_username"
- style="@style/normalText"/>
- <EditText
- android:id="@+id/username_edit"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:hint="@string/login_username_hint"
- android:layout_below="@id/login_user_input"
- android:singleLine="true"
- android:inputType="text"/>
- <!-- 密码 text -->
- <TextView
- android:id="@+id/login_password_input"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/username_edit"
- android:layout_marginTop="3dp"
- android:text="@string/login_label_password"
- style="@style/normalText"/>
- <EditText
- android:id="@+id/password_edit"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/login_password_input"
- android:password="true"
- android:singleLine="true"
- android:inputType="textPassword" />
- <!-- 登录button -->
- <Button
- android:id="@+id/signin_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/password_edit"
- android:layout_alignRight="@id/password_edit"
- android:text="@string/login_label_signin"
- android:background="@drawable/blue_button" />
- </RelativeLayout>
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- <TextView android:id="@+id/register_link"
- android:text="@string/login_register_link"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="15dp"
- android:textColor="#888"
- android:textColorLink="#FF0066CC" />
- <ImageView android:id="@+id/miniTwitter_logo"
- android:src="@drawable/cat"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_alignParentBottom="true"
- android:layout_marginRight="25dp"
- android:layout_marginLeft="10dp"
- android:layout_marginBottom="25dp" />
- <ImageView android:src="@drawable/logo"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_toLeftOf="@id/miniTwitter_logo"
- android:layout_alignBottom="@id/miniTwitter_logo"
- android:paddingBottom="8dp"/>
- </RelativeLayout>
- </LinearLayout>
四、Java源文件
Java源文件比较简单,只是实例化Activity,去掉标题栏。
- package com.mytwitter.acitivity;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.Window;
- public class LoginActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.login);
- }
- }
在开发APP的时候,需要设计登录界面的可以以此作为参考哦!
转载于:https://www.cnblogs.com/jiangu66/p/3238862.html
android登录界面相关推荐
- Android登录界面防劫持提醒处理
Android登录界面防止被劫持,目前没有好的反劫持方法,只能提醒用户登陆界面被劫持,具体实施如下: 涉及到的工具类: import android.app.ActivityManager; impo ...
- android登录界面扁平,Android EditText实现扁平化的登录界面
先来看看登录界面写完的效果图 2 监听editText,可以一键清空 3 checkBox的颜色统一 代码 下面,说说如何实现这个界面的,我将代码全部贴出来. xmlns:app="http ...
- Android 登录界面Demo源码
2019独角兽企业重金招聘Python工程师标准>>> 布局分析:分成三个部分,该Activity是一个无标题的,设置无标题需要在setContentView之前设置,否则会报错, ...
- android登陆界面设计方案,011android初级篇之android登录界面的设计
设计目标 密码账户的输入 输入账户时,自动显示匹配账户 没有帐号,显示官网超链接 登录框的自动提示功能参考一下链接中的AutoCompleteTextView的使用 布局文件 android:orie ...
- android登录界面居中,Android TextView前加图标垂直居中第一行(仿大众点评购买须知/提示语)...
如上图,需求在每条提示语句前加一个小圆点,我刚看到需求就想到用 android:drawableLeft 来做,可做完发现:当TextView内容为单行的时候是没有问题的,多行的时候,添加的这个dra ...
- android 登录界面开源代码_【程序源代码】一个安卓查询类app制作的开源项目
" 关键字:工作流 框架 springboot" 正文:一个学习安卓查询类app制作的开源项目.可以用来联系查询类app的编写. 01 - android studio最近势头好猛 ...
- android登录界面优化,Android 对登陆页面的美化(一)
对登陆页面的美化(一) 对EditeText的美化 非常简单的实现浮动标签EditText: Android视图使用EditText之上,并提示EditText时填充文本. 核心代码不超过50行 先上 ...
- Android实现仿QQ登录界面背景动画效果
登录QQ的时候,我们会看到在登录界面的背景不是静态的,而是一段动画效果,刚开始觉得蛮好奇的,现在我们也来实现一下这种效果,实现起来还是挺简单的. 实现步骤: 1.自定义CustomVideoView类 ...
- 怎么用Android做登录界面,利用Android怎么制作一个APP登录界面
利用Android怎么制作一个APP登录界面 发布时间:2020-12-02 17:09:10 来源:亿速云 阅读:79 作者:Leah 这期内容当中小编将会给大家带来有关利用Android怎么制作一 ...
最新文章
- ashx+jQuery,一个轻量级的asp.net ajax解决方案
- 1.3.1 单隐层网络的数学实现
- python修改html的td_python3修改HTMLTestRunner,生成有截图的测试报告,并发送测试邮件(一)...
- linux 默认文件属性,linux系统下文件的默认权限以及隐藏属性的作用
- Tabs vs Spaces:如何在Google,Twitter,Mozilla和Pied Piper上编写Java
- error: default argument given for parameter 4
- 进一步理解CSS浮动与清除浮动
- Ubuntu14.04配置python接口,测试的小问题
- vscode写python爬虫_如何在vscode中调试python scrapy爬虫
- shell类型、添加PATH环境变量、.bashrc、.profile、/etc/profile、/etc/environment
- leetCode:35. 搜索插入位置
- 编程基本功:while/for循环中,如果有switch,注意break是中断的哪一层
- Intel HD Graphics
- 如何挑选微信第三方开发商
- 苹果证书导出p12文件
- HTML5在vivo手机适配问题
- 使用python进行基音周期的计算
- 查询自己电脑的IP地址
- 【学习笔记-时间序列预测】prophet-使用.3节日与特殊事件
- 大学四年级(yuan)
热门文章
- php基础知识点及留言板功能实现
- 云厂商之战,战至“边缘”
- 保留thinkvantage一键恢复功能的Linux与vista双系统安装
- 【资料分享】《建筑给水排水设计标准》(GB50015-2019)
- Android 12 预览版带给我们的1234
- 2020安恒杯元旦月赛-爆破鬼才-ZIP注释信息+CRC32爆破+outguess隐写爆破+生日字典
- Windows下完全卸载node.js并安装node.js的多版本管理工具nvm-windows
- 如何使用PowerPoint在幻灯片背景中添加DRAFT水印?
- 中国计算机报陈翔照片,陈翔六点半茅台真名 陈翔六点半茅台扮演者是谁(茅台照片、简介)...
- c语言1000的阶乘有几个零,1000的阶乘后面有多少个零?