开源项目GridPasswordView使用和源码分析

一款简洁可自定义样式密码框输入组件GridPasswordView 通过继承TextView自定义实现的一款密码输入组件GridPasswordView,先上效果图: 动态效果图: 这里我根据自己经验做了样式定义与适配适配: 对于一些需求要求每个密码框式正方形也做了适配 支持定义密码框长度,密码可以明文或者密码显示 根据android的inputType类型来确认 增加闪动光标,可自定义样式 只需要在xml中定义显示样式就可以:<com.ttarfall.gri 阅读详情

GridPasswordView是一个密码输入视图,类似于微信或支付宝的支付密码视图。可以设置文字颜色和大小、分割线颜色、密码的长度。

项目地址:
https://github.com/Jungerr/GridPasswordView
其中包含项目源码和示例代码。

运行效果图:



一、项目使用
(1).在工程的build.gradle文件中添加项目引用。

dependencies {
    compile 'com.jungly:gridPasswordView:0.3'
}
(2).在布局中添加GridPasswordView。
<com.jungly.gridpasswordview.GridPasswordView
    android:id="@+id/gridpassword"
    android:layout_width="match_parent"
    android:layout_height="50dp" />
(3).添加Java代码。
GridPasswordView gridPasswordView = findViewById(R.id.gridpassword);
gridPasswordView.setOnPasswordChangedListener(new GridPasswordView.OnPasswordChangedListener() {
    @Override
    public void onTextChanged(String psw) {
        // add your code here
    }

    @Override
    public void onInputFinish(String psw) {
        // add your code here
    }
});

二、源码分析
实现原理:
整个网格密码输入框最外层是一个水平方向的LinearLayout,内部包括显示密码的View和垂直分隔线View。而多个显示密码的View中,第一个位置放置的是EditText,其余均为TextView。如图所示。


当LinearLayout被点击时,让EditText获取焦点并弹出软键盘。定义一个String类型数组保存已输入的密码,当监听到EditText有新的字符输入时,截取下来保存到数组中,并保持EditText中始终只存在一个字符。每当监听到EditText的退格键时,删除String数组的最后一条数据。最后遍历String数组得到的就是用户输入的密码。
密码控件passwordView及其分析 1.做app,尤其是金融类的app,往往都会涉及到支付密码这块,并且支付密码几乎都是6个数字,1个数字占一个区域,6个数字占满整个区域,并且每个数字占得大小是相等的,类似于以下的样子 2. 那么怎么样才能做出这样一个控件呢,可以看到每个数字是等大小的,并且是会显示在中间的 3.我们在考虑的时候肯定是输入东西,第一控件就是EditText,因为这个控件是支持输入的。但是我们要求的刚好6个数字 阅读详情

相关推荐

圆形图片CircleImageView的使用和分析

在项目开发中,我们经常需要用到圆形图片效果,典型案例是用户头像的显示。 如图所示。 下面我们使用开源控件CircleImageView来实现该效果。 CircleImageView项目下载地址: https://github.com/hdodenhof/CircleImageView (1).CircleImageView的使用 首先我们将CircleImage

ruancoder的博客 2万+

PassWordView:6格数字密码、验证码输入控件

PassWordViewDemo <com.lxj.passView.view.PassWordLayout android:id="@+id/passLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/tv_tipsinfo" android:layout_marginTop="44px" app:box_draw_type="rect" app:interval_width="4" app:item_height="35" app:item_width="35" app:pass_inputed_type="stars" app:

GridPasswordview

微信等商城App密码输入框,使用demo

angular仿支付宝密码框输入效果

本篇文章主要介绍了angular仿支付宝密码框输入效果,详细的介绍了使用ng写一个密码框格子支付模块,具有一定的参考价值,有兴趣的可以了解一下。

从零到一:R与RStudio的安装与配置全攻略

本文提供了R与RStudio的完整安装与配置指南,涵盖Windows、Mac和Linux三大操作系统。从基础环境搭建到高级性能优化,详细介绍了R语言安装、RStudio配置、项目管理和实用技巧,帮助数据科学初学者快速搭建高效的分析工作环境。

weixin_29062671的博客 419

Python-uiautomator2保姆级安装指南:从环境配置到设备连接全流程

本文提供Python-uiautomator2的保姆级安装指南,涵盖从环境配置到设备连接的全流程。详细介绍了Python 3.6+、ADB工具等核心组件的准备,以及uiautomator2的安装和设备端服务初始化步骤,帮助开发者快速搭建Android自动化测试环境,避免常见问题。

nnn11的博客 936

机械臂开发必备:KDL库正逆解与动力学实战指南

在机器人算法领域,运动学与动力学计算是机械臂控制、仿真与轨迹规划的核心基础。正运动学描述关节空间到笛卡尔空间的映射,逆运动学则需要求解复杂的非线性方程,工程实现时常面临数值稳定性与调试效率的挑战。KDL(Kinematics and Dynamics Library)作为ROS生态中广泛使用的开源库,提供了统一的模型描述与高效求解器,将正逆解、雅可比矩阵及动力学参数计算封装为简洁接口,大幅降低开发门槛。无论是机械臂的笛卡尔空间轨迹跟踪,还是基于动力学模型的前馈控制,KDL都展现出强大的工程价值。本文从运动学

weixin_33860528的博客 2504

MATLAB Appdesigner开发独立桌面App全流程(一):以打开串口功能为例介绍Appdesigner的基本使用

本文详细介绍了Appdesigner的基本使用,以串口功能为例介绍按钮回调函数的实现以及控件之间通信的问题

Zhuwany的博客 3万+

YOLOv8损失函数改进大全:从IoU到FocusIoU的20+种变体全解析(附完整适配代码+性能对比)

目标检测边界框损失函数演进与优化 摘要:边界框损失函数是目标检测模型定位精度的关键因素。本文系统分析了从基础IoU到最新FocusIoU的20余种损失函数的演进历程,包括四代主要技术:基于重叠区域的IoU/GIoU,结合距离度量的DIoU/CIoU,优化形状匹配的EIoU/RIoU,以及考虑方向性的SIoU/WIoU/FocusIoU。针对YOLOv8模型,提供了完整的损失函数实现代码和替换方案,实验表明优化后的损失函数在复杂场景下可提升mAP@0.5达3.2%。文章特别对比了不同损失在小目标、遮挡和密集场

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 996

飞塔CVE-2022-40684复现

admin 无密码直接回车(会提示修改密码)

G3et的博客 1144

人工智能---什么是Transformer?

Transformer是一种强大的神经网络架构,最初由Google的研究人员在论文《Attention is All You Need》中提出,用于自然语言处理任务,特别是在机器翻译方面取得了巨大成功。Transformer的核心思想是完全基于自注意力机制(self-attention mechanism)来实现序列到序列(sequence-to-sequence)的学习。它在自然语言处理(NLP)和其他序列到序列任务中表现出色,逐渐成为该领域的主流模型。近些年也逐渐在自动驾驶领域有所应用。

智能汽车人的博客 3954

使用HART Server PC软件进行HART设备的组态、调试和分析的完整指南

HART协议是一种用于工业自动化中的双向通信协议,能够在4-20mA模拟信号的基础上叠加数字信号,从而实现设备的远程监控和管理。HART协议兼具模拟和数字通信的优点,被广泛应用于过程控制系统中。设备组态:通过软件可以对HART设备进行组态,配置设备参数。设备调试:支持设备的在线调试和故障诊断,方便快速解决问题。数据分析:提供设备运行数据的实时监控和历史数据分析功能。报表生成:支持生成各类报表,便于数据记录和管理。

qq_38334677的博客 2468

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

上一篇: 使用ZXing扫描和生成二维码
下一篇: 开源项目ToggleButton源码分析
ruancoder
博客等级 码龄10年 42粉丝 66原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值