In Android development, there are many situations where we need to use the dialog box, unfortunately, Android's own dialog box style does not meet our actual needs, so we often need to customize the dialog box, the Practice: Write a dialog box inherits from the dialog implementation of his one of the construction method (depending on your usage) , which is handled in OnCreate (). Of course, more cases, you do not need to write, will copy code is also a kind of ability, here I introduce a bottom pop-up dialog box, I hope to your study and work to help, the following is:
Here are the specific practices:
Import Dependent libraries:
Dependencies { 'com.github.rey5137:material:1.2.2'}
This is a dependency library based on the material design of githup, which is optimized for this library.
Here is the implementation code:
bottominterpassworddialog = new Bottomsheetdialog ( Homeactivity. Viewinterpassword)
. Heightparam (windowhight/3)
. Induration (500)
. Ininterpolator (new bounceinterpolator ())
. Outinterpolator ( Span style= "color: #000080; Font-weight:bold; " >new anticipateinterpolator ())
. cancelable (true)
. Show () ;
A line of code, easy to implement,Contentview Added dialog view,induration into the screen time,ininterpolator into the screen animation, cancelable , if you click to exit the dialog box,heightparam Displays the height of the dialog. where Interpolator
There are several definitions in Android:
Acceleratedecelerateinterpolator rate changes at the beginning and end of the animation are slower, accelerating in the middle
Accelerateinterpolator at the beginning of the animation the rate change is slow, and then start to accelerate
Anticipateinterpolator starts back and then moves forward.
Anticipateovershootinterpolator starts back and then dumps a certain value and returns the last value.
Bounceinterpolator animation at the end of the play
Cycleinterpolator Animation Loop plays a specific number of times, rate changes along the sine curve
Decelerateinterpolator in the beginning of the animation and then slowly
Linearinterpolator change at constant rate
Overshootinterpolator forward a certain value before returning to its original position.
Of course, if this doesn't meet your needs, you can define it yourself. Very simple, I do not say here, I hope this blog to help you, if you have any questions welcome the message below.
Android Development Combat Bottom dialog pop-up effect