android方块密码输入框,Android仿微信/支付宝的方块密码输入框
在用到支付类或者验证类app时,都有一个简密的输入框。百度了下有个不错的帖子点击打开链接
不过自己也写了个简单的类似的。不废话了。没图说个席八。
懒得运行,直接截layout.xml的效果图先。
布局文件
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:paddingBottom="20dp"
android:paddingTop="30dp" >
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="请输入验证码"
android:textStyle="bold"
android:textSize="22sp" />
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/i1"
android:gravity="center"
android:inputType="number"
android:lines="1"
android:maxLines="1" />
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/i1"
android:gravity="center"
android:inputType="number"
android:lines="1"
android:maxLines="1" />
android:id="@+id/t3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/i1"
android:gravity="center"
android:inputType="number"
android:lines="1"
android:maxLines="1" />
android:id="@+id/t4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/i2"
android:gravity="center"
android:inputType="number"
android:lines="1"
android:maxLines="1" />
android:id="@+id/editHide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/layout"
android:layout_alignLeft="@+id/layout"
android:layout_alignRight="@+id/layout"
android:layout_alignTop="@+id/layout"
android:layout_weight="1"
android:background="#00000000"
android:cursorVisible="false"
android:ems="10"
android:inputType="number"
android:maxLength="4"
android:textColor="#00000000" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/layout"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" >
android:id="@+id/verifycode_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#fa8d70"
android:layout_marginRight="30dp"
android:textColor="#ffffff"
android:text="确定" />
android:id="@+id/verifycode_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:background="@color/index_time_but"
android:textColor="#ffffff"
android:text="取消" />
代码:
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView t1, t2, t3, t4, et;
String key = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.verifycode);
t1 = (TextView) findViewById(R.id.t1);
t2 = (TextView) findViewById(R.id.t2);
t3 = (TextView) findViewById(R.id.t3);
t4 = (TextView) findViewById(R.id.t4);
et = (EditText) findViewById(R.id.editText1);
et.addTextChangedListener(tw);
}
void setKey() {
char[] arr = key.toCharArray();
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
for (int i = 0; i < arr.length; i++) {
if (i == 0) {
t1.setText(String.valueOf(arr[0]));
} else if (i == 1) {
t2.setText(String.valueOf(arr[1]));
} else if (i == 2) {
t3.setText(String.valueOf(arr[2]));
} else if (i == 3) {
t4.setText(String.valueOf(arr[3]));
}
}
}
TextWatcher tw = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
key = s.toString();
setKey();
}
};
}
好哒。就这样了。运行就有效果了。没有什么自定义,没有什么第三方。
当然。如果你要弹窗形式的话,也一样,加下面的就能弹窗了
final AlertDialog dialog = new AlertDialog.Builder(mContext).create();
dialog.show();
dialog.getWindow().setContentView(R.layout.verifycode);t1 = (TextView) dialog.findViewById(R.id.t1);
t2 = (TextView) dialog.findViewById(R.id.t2);
t3 = (TextView) dialog.findViewById(R.id.t3);
t4 = (TextView) dialog.findViewById(R.id.t4); 后期有时间再补上项目DOME。下班。走人
android方块密码输入框,Android仿微信/支付宝的方块密码输入框相关推荐
- android微信风格,Android实用View系列-----仿微信支付宝等风格的支付密码输入框的实现...
开始阅读本篇文章之前先来说一下使用场景吧,我们知道如今移动支付已经占据我们日常支付的90%的份额,以微信支付和支付宝支付为主,也越来越多的APP开始添加支付模块,不管使用哪种支付有一个步骤是少不了的, ...
- android微信点赞ui,Android中使用PopupWindow 仿微信点赞和评论弹出
微信朋友圈的点赞和评论功能,有2个组成部分:左下角的"更多"按钮:点击该按钮后弹出的对话框: PopupWindow,弹出框使用PopupWindow实现,这是点赞和评论的载体,具 ...
- Android录制视频,仿微信小视频录制(一)
Android录制视频,第一部分自定义控件 简述 公司有一个录制视频并上传的功能,录制视频具体使用类如下:硬件控制使用Camera,视频录制的格式音频等具体配置与录制使用MediaRecorder,预 ...
- 仿微信支付宝支付密码
仿微信支付宝支付密码 效果图: 一.主要知识点 GridLayout的应用 EditText的textCursorDrawable的应用 InputMethodManager的应用 TextWatch ...
- Android开发技巧——定制仿微信图片裁剪控件
拍照--裁剪,或者是选择图片--裁剪,是我们设置头像或上传图片时经常需要的一组操作.上篇讲了Camera的使用,这篇讲一下我对图片裁剪的实现. 背景 下面的需求都来自产品. 裁剪图片要像微信那样,拖动 ...
- Android 混合开发之仿微信朋友圈
开发之前 大约从去年开始吧, 也可能是前年 Html5好像火得不得了, 不得了-总能从网上听说到 XXX混合开发, 为了紧跟潮流(虽然有点儿晚了), 咱们也看看Android+Html5混合开发是怎样 ...
- android 辐射动画_Android仿微信雷达辐射搜索好友(逻辑清晰实现简单)
不知不觉这个春节也已经过完了,遗憾家里没网,没能及时给大家送上祝福,今天回到深圳,明天就要上班了,小伙伴们是不是和我一样呢?今天讲的是一个大家都见过的动画,雷达搜索好友嘛,原理也十分的简单,你看完我的 ...
- Android自定义ListView实现仿微信侧滑删除
经常在遇到问题第一时间都会在网上搜索解决的方法,因此看到很多前辈们的比较精辟的技术文章,学习了很多东西,现在将自己平时工作中开发的一些小功能坐下总结,也写出来,既方便自己理清思路记忆功能块实现思路,又 ...
- Android自定义View分享——仿微信朋友圈图片合并效果
写在前面 笔者近来在学习Android自定义View,收集了一些不算复杂但又"长得"还可以的自定义View效果实现,之前分享过两个效果:一个水平的进度条,一个圆形温度显示器,如果你 ...
最新文章
- 劲爆!java的学习网站
- Java入门算法(树篇)
- 实现linux cp 命令和修改配置文件
- having和where可以同时使用吗_阴、阳离子聚丙烯酰胺可以同时混合溶解使用吗?...
- 详解CentOS7安装配置vsftp搭建FTP
- Nginx学习之九-负载均衡(客户端请求与Nginx进程间负载均衡)
- ORACLE数据库事务隔离级别
- 集成学习框架-学习小结20161121
- 【强化学习】表格型求解方法总结:基于表格型方法(Tabular Methods)的规划(Planning)和学习(Learning)
- 你还在用HTTP吗?HTTP/3都来了。。。
- 中国银行刘东海:净值产品短期难当主角 需关注资产集中处置风险
- python基础(一):入门必备知识
- Docker使用过程中经常遇见的问题
- 2017年5月—信息安全工程师—上午综合知识(11-15)
- SYNOPSYS™光学设计软件---设计自由曲面反射系统
- google 搜索跳转至yahoo
- 凸优化理论(一)数学优化问题的分类
- 软件硕士和计算机硕士,详解软件工程硕士和计算机硕士区别
- 《今日简史》2018比尔盖茨推荐(pdf, mobi, epub三种格式)
- 综合布线施工工艺--
热门文章
- Dapr 运用之集成 Asp.Net Core Grpc 调用篇
- 东南亚的IT公司,我劝你善良!
- Asp.Net Core中的静态文件-12
- asp.net core webApi 参数保护
- look look C#7
- Entity Framework Core 1.1 升级通告
- 使用StyleCop 进行代码评审
- SignalR的性能监测与服务器的负载测试
- spark写出分布式的训练算法_利用 Spark 和 scikit-learn 将你的模型训练加快 100 倍...
- 高可用架构可行性方案