Implement IOS style bottom selector in Android Development (support time and date customization)
GitHub code link for this article
https://github.com/AndroidMsky/AndoirdIOSPicker
Let's start with the picture above:
This is a selector library that has been reused by the author in a recent project. I also modified it and decided to maintain it continuously.
Let's see how to use it first:
Date selection:
It's relatively simple, so I won't explain it
Custom selection:
Make a list first
Then, when you call, you can import this list.
Next, we will simply analyze the principle of timepick, which is also convenient for us to make custom extensions.
First, open timepickerdialog. You can see that it inherits from dialog. You are not familiar with custom dialog. You can see:
Builder mode analysis under Android + custom dialog practice
http://blog.csdn.net/androidmsky/article/details/52982815
I'm sure the dialog will use the builder mode. Next, let's look at the fields inside
We see that the main force is two loopviews to represent hours and minutes. Next, we will look at loopviews. When we go in, we will find relatively large parameters with a face. Don't be afraid, let's go straight to its two most critical methods,
You can see that even if you are drawing words, don't be afraid to repeat them. There are just a few methods:
When it is called in several cases, it must be a different style of 12345 position numbers
The next key method is:
Change the offset value of the drawing through the movement of the finger:
This is probably the posture to see the open source custom view.
The above is the implementation of IOS style bottom selector (supporting time and date customization) in Android development introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!