仿智联招聘注册页面输入框
原图效果
实现效果
代码
首先来定义需要用到的自定义属性:
<declare-styleable name="AnimatorLineEditText"><!--失去焦点底部横线的颜色--><attr name="defaultColor" format="color"/><!--获取焦点后 底部横线的颜色--><attr name="focusColor" format="color"/><!--失去焦点底部横线的 宽度--><attr name="defaultStrokeWidth" format="dimension"/><!--获取焦点底部横线的 宽度--><attr name="focusStrokeWidth" format="dimension"/></declare-styleable>
java代码
public class AnimatorLineEditText extends AppCompatEditText{private Paint mPaint;private int mWidth;private int mHeight;private float mProgress = 0;private int mFocusStrokeWidth = 5;private int mDefaultStrokeWidth = 2;private int mFocusColor = Color.parseColor("#FF4081");private int mDefaultColor = Color.parseColor("#999999");@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)public AnimatorLineEditText(Context context) {this(context, null);}@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)public AnimatorLineEditText(Context context, AttributeSet attrs) {super(context, attrs);TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AnimatorLineEditText);mFocusStrokeWidth = (int) a.getDimension(R.styleable.AnimatorLineEditText_focusStrokeWidth, mFocusStrokeWidth);mDefaultStrokeWidth = (int) a.getDimension(R.styleable.AnimatorLineEditText_defaultStrokeWidth, mDefaultStrokeWidth);mDefaultColor = a.getColor(R.styleable.AnimatorLineEditText_defaultColor, mDefaultColor);mFocusColor = a.getColor(R.styleable.AnimatorLineEditText_focusColor, mFocusColor);a.recycle();setBackground(null);mPaint = new Paint();mPaint.setAntiAlias(true);mPaint.setStyle(Paint.Style.STROKE);mPaint.setStrokeWidth(mDefaultStrokeWidth);mPaint.setColor(mDefaultColor);}@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {mWidth = MeasureSpec.getSize(widthMeasureSpec);mHeight = MeasureSpec.getSize(heightMeasureSpec) + mFocusStrokeWidth;setMeasuredDimension(mWidth, mHeight);setOnFocusChangeListener(new OnFocusChangeListener() {@Overridepublic void onFocusChange(View view, boolean b) {if (b) {setFocus();}else{setUnFocus();}}});}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);mPaint.setColor(mDefaultColor);mPaint.setStrokeWidth(mDefaultStrokeWidth);canvas.drawLine(0, mHeight - mDefaultStrokeWidth, mWidth, mHeight - mDefaultStrokeWidth, mPaint);mPaint.setColor(mFocusColor);mPaint.setStrokeWidth(mFocusStrokeWidth);canvas.drawLine(mWidth / 2, mHeight - mFocusStrokeWidth, mWidth / 2 - mProgress, mHeight - mFocusStrokeWidth, mPaint);canvas.drawLine(mWidth / 2, mHeight - mFocusStrokeWidth, mWidth / 2 + mProgress, mHeight - mFocusStrokeWidth, mPaint);}private void setFocus(){ValueAnimator animator = ValueAnimator.ofFloat(0, mWidth / 2);animator.setDuration(500);animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {@Overridepublic void onAnimationUpdate(ValueAnimator valueAnimator) {mProgress = (float) valueAnimator.getAnimatedValue();postInvalidate();}});animator.start();}private void setUnFocus(){ValueAnimator animator = ValueAnimator.ofFloat(mWidth / 2, 0);animator.setDuration(500);animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {@Overridepublic void onAnimationUpdate(ValueAnimator valueAnimator) {mProgress = (float) valueAnimator.getAnimatedValue();postInvalidate();}});animator.start();}
}
使用
<com.lanbaoapp.keyboarddemo.AnimatorLineEditTextandroid:layout_width="match_parent"android:layout_height="50dp"android:hint="请输入账号"android:textSize="14sp"app:focusColor="@color/colorPrimary"/>
项目有类似效果的可以直接拿去使用!!!
仿智联招聘注册页面输入框相关推荐
- 仿智联招聘首页html源码,模仿智联职位选择,地区选择Js插件
[实例简介] 模仿智联职位选择,地区选择Js插件,界面需要做简单的修改 [实例截图] [核心代码] jquery-plugin-ExtendedBoxy └── jquery-plugin-Exten ...
- 仿智联招聘实现简历导出功能
if Trim(request("Action"))="daochu" then 导出到excel dim Num,xlApplication,xlWorksh ...
- scrapy由浅入深(三) selenium模拟爬取ajax动态页面(智联招聘)
爬取智联招聘的网址:https://sou.zhaopin.com/?pageSize=60&jl=489&kw=python&kt=3 上一篇博客爬取了前程无忧的职位招聘信息 ...
- 智联招聘数据爬取准备(2)-招聘信息页面及企业主页源码解析
网页源码解析 - 智联招聘信息页面 根据招聘列表里面跳转过来的详细招聘信息页面.爬虫再根据这里进行关键信息提取. 相比于搜索列表页来说,这页内容很简单,而我们需要的也不多. 不过需要注意的是,这里在职 ...
- 智联招聘数据爬取准备(1)-智联招聘搜索列表源码解析
网页源码解析 - 智联招聘搜索列表 一开始必须要解析智联招聘搜索列表页,从这里更方便实现各种深层级数据抓取. 网页地址是: http://sou.zhaopin.com/jobs/searchresu ...
- python爬虫获取智联招聘信息
智联招聘的页面信息是jsonp传输的数据,所以抓包或者正常爬取内容不可能的是,下面我将分享分析出来的数据并整体操作步骤.用谷歌浏览器打开网址,并打开检查,里面有network选项,包含这个网页的请求响 ...
- vue前端服务器端口_解密智联招聘的大前端架构 Ada
作者 | 智联大前端 Ada 是智联招聘自主研发的演进式大前端架构.于 2017 年正式投入使用后,又经过三年持续演进,全面覆盖了从研发到运维的各个方面,具备跨技术栈工程化体系.交互式图形界面开发工具 ...
- 基于分布式的智联招聘数据的大屏可视化分析与预测
项目需求分析及体系架构 1.1项目介绍 互联网成了海量信息的载体,目前是分析市场趋势.监视竞争对手或者获取销售线索的最佳场所,数据采集以及分析能力已成为驱动业务决策的关键技能.<计算机行业岗位招 ...
- 招聘网站分析-智联招聘网的爬虫设计与实现
爬虫文件 原理 1.分析 智联招聘网是招聘网站中爬取难度最高的网站.为了减轻爬虫对网站运营的影响,要求用户必须注册登录,否则提示登录后才能进行信息检索. 智联招聘网的页面布局以及列表页请求url.注册 ...
最新文章
- 看图理解scrollTop,scrollLeft,clientWidth,clientHeight,offsetWidth,offsetHeight
- swiper高度自适应_小程序自定义导航自适应高度
- Repeater,DataList,DataGrid 【转】
- Good Numbers(HDU5447+唯一分解)
- npm和angular_如何开发,使用和发布Angular库到NPM
- 我的内核学习笔记2:platform设备模型
- 传西门子中国运营中近一半业务涉及行贿
- 【图像处理】canny和sobel边缘检测__python-opencv
- JSP实用教程 第二章 JSP语法
- 《Shell脚本学习指南》学习笔记
- Android签名概要总结——对称加密/非对称加密、数字签名、公钥证书、ca认证机构、安卓app签名
- 华为服务器sn码查询网站,linux 查询服务器sn号
- 自动驾驶最全基础知识、课程、论文、数据集、开源软件等资源整理分享
- Unity4.3.1引擎源码编译过程
- 自己整理的机器学习算法应用指南
- BigData之Hadoop:Hadoop框架(分布式系统基础架构)的简介(两大核心【HDFS存储和MapReduce计算】)、深入理解、下载、案例应用之详细攻略
- char、int、long它们各占几个字节?占几位?
- 【unity】Google 登录和Google支付接入unity
- input隐藏边框轮廓、输入框输入提示
- 数据仓库主题设计及元数据设计