In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to imitate the password input effect of Alipay by Android". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Android how to achieve imitation Alipay password input effect" bar!
Effect picture
1, how to use, you can set your own entry and exit animation, if not set, there is no animation effect, I think it is very good to use after encapsulation.
Private MyInputPwdUtil myInputPwdUtil;@Overrideprotected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); myInputPwdUtil = new MyInputPwdUtil (this); myInputPwdUtil.getMyInputDialogBuilder () .setAnimStyle (R.style.dialog_anim); / / you can customize the entry and exit animation without setting myInputPwdUtil.setListener (new InputPwdView.InputPwdListener () {@ Override public void hide () {myInputPwdUtil.hide ()) } @ Override public void forgetPwd () {Toast.makeText (MainActivity.this, "forgot password", Toast.LENGTH_SHORT). Show ();} @ Override public void finishPwd (String pwd) {Toast.makeText (MainActivity.this, pwd, Toast.LENGTH_SHORT). Show ();}});} public void show (View view) {myInputPwdUtil.show ();}
2. The input box implements the main code, which is to draw a rectangle and a circle in the middle.
Int height = getHeight (); int width = getWidth (); / / frame RectF rect = new RectF (0,0, width, height); borderPaint.setColor (borderColor); canvas.drawRoundRect (rect, borderRadius, borderRadius, borderPaint); / / drawing content area RectF rectContent = new RectF (rect.left + defaultContentMargin, rect.top + defaultContentMargin, rect.right-defaultContentMargin, rect.bottom-defaultContentMargin); borderPaint.setColor (getResources (). GetColor (R.color.myInputPwdBase_gray)); canvas.drawRoundRect (rectContent, borderRadius, borderRadius, borderPaint) / / draw split lines: the number of split lines is 1 borderPaint.setColor (borderColor) less than the number of passwords; borderPaint.setStrokeWidth (defaultSplitLineWidth); for (int I = 1; I < passwordLength; inumbers +) {float x = width * I / passwordLength; canvas.drawLine (x, 0, x, height, borderPaint);} / / draw password content float px, py = height / 2; float halfWidth = width / passwordLength / 2; for (int I = 0; I < textLength; inumbers +) {px = width * I / passwordLength +) Canvas.drawCircle (px, py, passwordWidth, passwordPaint);}
3. Module, as a library, had better be able to distinguish and set a specific beginning when defining the properties used, so as to avoid conflicts after the introduction of your own project.
At this point, I believe that everyone on the "Android how to achieve imitation Alipay password input effect" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.