android 支付宝登录界面,模仿支付宝登录页的实现(android)
先看看支付宝登录页面长什么模样
首先 看见图 先分析 登录页面所需要的元素——需要一个ImageView 存放用户头像
接下来就是账号密码输入框了 (里面的细节在于 当开始输入的 在编辑框后面会出现一个小叉,用于删除文本,该选中的框 下面的那条线会变蓝色)
再往下面 就是button了
接下来我们就开始考虑方案——1.头像 (我们可以使用fresco库来加载图片,具体用法这里不提了)
2.两个输入框(这里面的输入框的功能都差不多,可以考虑封装成一个控件,达到复用的效果)
3.剩下的Button随意就好
接下来 主要说的就是 自定义这个输入框的方法了
step1:
新建attrs.xml
这个属性代表账号还是密码的说明 对比原图应该就能懂了
删除按钮的图标的地址
更多图标的地址(一开始密码,账号没想过合在一起,后面为了省事,这里也代表密码框开始可视图标的地址)
原支付宝 输入框获得焦点时,下面那条线会变蓝 so
这两个属性就是为了这个
代表输入框没有输入的提示
表示这个空间是普通控件 还是密码框
step2:
新建布局文件
android:layout_width="match_parent" android:layout_height="55dp"
android:gravity="center_vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp">
android:layout_marginLeft="15dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="账号"
android:textColor="@android:color/black"
android:id="@+id/tv_account"
/>
android:gravity="left|center_vertical"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="@null"
android:singleLine="true"
android:id="@+id/et_account"
android:hint="请输入账号"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:password="false" />
android:padding="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:src="@drawable/eye"
android:id="@+id/iv_more"
android:layout_above="@+id/v_line"
/>
android:padding="5dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/arrowdown"
android:layout_above="@+id/v_line"
android:visibility="visible"
android:layout_toLeftOf="@id/iv_more"
android:id="@+id/iv_del" />
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#4000"
android:layout_alignParentBottom="true"
android:id="@+id/v_line" />
step3:
新建类:
/**
* Created by wangjie on 15/8/11.
*/
public class AccountInputView extends RelativeLayout {
private EditText etAccount;
private View vLine;
private ImageView ivDel;
private ImageView ivMore;
private TextView tvAccount;
private CharSequence accountText;
private int lineColor;
private Drawable delDrawable;
private Drawable moreDrawable;
private boolean delShow;
private CharSequence etHint;
private int lineColorSelect;
private int mode;
private final static int MODE_NORMAL=0;
private final static int MODE_PASSWORD=1;
private int currentMode=0;
public EditText getEtAccount(){
return etAccount;
}
public AccountInputView(Context context) {
super(context);
}
private void initView(final Context context) {
LayoutInflater
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.view_account_input,
this);
tvAccount= (TextView) findViewById(R.id.tv_account);
vLine=findViewById(R.id.v_line);
ivDel= (ImageView) findViewById(R.id.iv_del);
ivMore= (ImageView) findViewById(R.id.iv_more);
etAccount= (EditText) findViewById(R.id.et_account);
if(mode== MODE_PASSWORD){
currentMode=MODE_PASSWORD;
etAccount.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
if(!TextUtils.isEmpty(accountText)){
tvAccount.setText(accountText);
}
if (lineColor !=0){
vLine.setBackgroundColor(lineColor);
}
ivDel.setImageDrawable(delDrawable);
ivMore.setImageDrawable(moreDrawable);
if(delShow)
{
ivDel.setVisibility(View.VISIBLE);
}else {
ivDel.setVisibility(View.INVISIBLE);
}
if(!TextUtils.isEmpty(etHint)){
etAccount.setHint(etHint);
}
etAccount.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
vLine.setBackgroundColor(lineColorSelect);
else
vLine.setBackgroundColor(lineColor);
}
});
etAccount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (!TextUtils.isEmpty(s))
ivDel.setVisibility(VISIBLE);
else
ivDel.setVisibility(INVISIBLE);
}
});
ivDel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
etAccount.setText("");
}
});
ivMore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mode == MODE_PASSWORD) {
if (currentMode == MODE_PASSWORD) {
etAccount.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
ivMore.setImageResource(R.drawable.eye);
currentMode = MODE_NORMAL;
} else if (currentMode == MODE_NORMAL) {
etAccount.setTransformationMethod(PasswordTransformationMethod.getInstance());
ivMore.setImageResource(R.drawable.eyenormal);
currentMode = MODE_PASSWORD;
}
Editable editable = etAccount.getText();
Selection.setSelection(editable, editable.length());
} else if (mode == MODE_NORMAL) {
Toast.makeText(context, "这里将展示一些纪录", Toast.LENGTH_LONG).show();
}
}
});
}
public AccountInputView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.AccountInputView);
accountText = array.getText(R.styleable.AccountInputView_accountText);
lineColor = array.getColor(R.styleable.AccountInputView_lineColor, getResources().getColor(R.color.lineColorDefault));
delDrawable = array.getDrawable(R.styleable.AccountInputView_delSrc);
moreDrawable = array.getDrawable(R.styleable.AccountInputView_moreSrc);
delShow = array.getBoolean(R.styleable.AccountInputView_delShow, false);
etHint = array.getText(R.styleable.AccountInputView_etHint);
lineColorSelect = array.getColor(R.styleable.AccountInputView_lineColorSelect, getResources().getColor(R.color.lineColorBule));
mode = array.getInt(R.styleable.AccountInputView_mode, 0);
initView(context);
array.recycle();
}
}
到此 支付宝登陆界面所使用的输入框就基本完了,还有下拉选择账号的功能后面再说吧
android 支付宝登录界面,模仿支付宝登录页的实现(android)相关推荐
- PyQt:个性化登录界面模仿QQ登录
写在前面 写了一个登录界面的demo,类似QQ的,写的自己喜欢的样式,贴一下代码,先上效果,如下 陈述 PyQt5+Python3.5.2 login.py是里登录的主界面loginWnd类,Head ...
- QQ登录界面模仿和事件监听(下)
我们到了QQ登录界面模仿这个环节了. 当开始做一个小小的程序的时候,就发现事件监听的无处不在.因为如果让一个程序有能动性,人使用时根据需要程序也能做出相应的反应,很多时候都要使用事件监听. (当时俺的 ...
- 玩转Windows个性化登录界面 (更换Windows7登录界面图片/XP仿Win7登录界面)
玩转Windows个性化登录界面 (更换Windows7登录界面图片/XP仿Win7登录界面)
- 登录界面的验证登录以及session的使用
登录界面的验证登录以及session的使用 一.实验要求 (1) 新建 login.jsp 页面,其中,包含登录所需用户名与密码字段. 以及提交(input)和重新填写按钮(reset):表单meth ...
- java支付宝网页授权登录界面_支付宝开发平台之第三方授权登录与获取用户信息...
对于第三方登录,我们常见了,很多应用可以进行第三方登录,我常用的有:QQ.微信.新浪.支付宝等等,今天我们就一起来简单学习一下支付宝第三方授权登录. 打开支付宝开发平台,注册成为开发者,点击开发者中心 ...
- pyqt5登录界面设计——模仿qq登录界面,可登录注册(数据库)
pyqt5登录界面设计--模仿qq登录界面 一.简单易用的可直接登录的界面--账号密码程序写死 1.1.效果图: 1.2.视频效果图 3.代码说明 4.使用示例 5.全部源码见: 二.带数据库的可登录 ...
- linux登录界面说明,Linux登录界面以及简单使用入门
一.登录界面介绍 安装完操作系统以后,就进入到linux登录界面,linux默认登录界面可以分为:字符界面和图形界面: 图形界面如下所示: 字符界面如下所示: 字符登录界面的含义: CentOS re ...
- java图形用户登录界面_Java简单登录图形界面
一.登录界面 1.程序代码 1 import java.awt.*;//导入awt包 2 import javax.swing.*;//导入swing包 3 import java.awt.event ...
- python成绩登录界面_python实现登录界面
关注公众号:Python爬虫数据分析挖掘,回复[开源源码]免费获取更多源码 本例,展示了通过登录界面打开主界面的实现方式. 其中,登录的账号与密码判断都比较简单,请大家根据自己需要,自行完善补充. [ ...
- php静态登录界面代码,JSP_JSP登录验证功能的实现,静态的登录界面的设计login.htm - phpStudy...
JSP登录验证功能的实现 静态的登录界面的设计login.htm,代码如下: 系统登录 系 统 登 录 用户名 密 码 将登录用户输入的信息提交到login.js ...
最新文章
- 2022-2028年中国改性尼龙行业市场全景评估及产业前景规划报告
- 如何让决策树中有样本的索引
- 合同模板布局html,套打模板制作(合同类模板)
- 今天JKS挂了,记录一下手动发云机上流程
- 《Web前端工程师修炼之道(原书第4版)》——我该从哪里开始呢
- linux内核杂记(3)-进程(1)
- (案例)使用Cookie保存用户最后一次访问的时间
- 圆与平面的接触面积_视频:5.3RJ六年级上册圆的面积例题+习题讲解
- 纯小白成功安装交叉编译工具arm-none-eabi-gcc
- CentOS 6.2安装配置pacemaker
- ERD-ONLINE 免费在线数据库建模工具
- js 跨域下载链接 下载文件 实现重命名,文件名称 兼容处理
- ai怎么渐变颜色_AI的渐变工具为什么如此难用?
- 微信小说域名被封-366tool在线解答微信屏蔽小说网页停止访问的解决方案
- cf1504E - Travelling Salesman Problem
- win10计算机丢失msvcr,计算机中丢失msvcr110.dll怎么办?Win10系统中丢失msvcr110.dll解决方法...
- 无源码程序反编译修改文字
- android涂鸦实现
- Linux内核下载(包括历史版本)
- 在 Laravel 中使用 Tailwind CSS
热门文章
- c盘分小了如何扩大c盘,重新分区扩大c盘
- 无线专题 PCI接口与PCIe接口
- 计算机联锁控制系统的软件应具备信号操作功能,N6_计算机联锁控制系统原理-软件原理.ppt...
- 手机屏幕上的战争 三星领先苹果半步
- 6U VPX数据存储板学习资料保存:基于6U VPX 的mSATA高性能数据存储板
- BetterZip 4.2.4 激活版下载安装– Mac上最快速的压缩工具
- Skype for Business Server前端高可用原理分析
- 微信小程序安全需求基线
- 【23种设计模式】【单例模式】
- 鹏业安装算量软件一键识别设备操作说明