Presentation:
First, an overview of the implementation:
Then a demonstration of the individual effects:
Displacement animation demonstration:
Zoom animation demo:
Transparency animation demo:
Rotation animation demo:
Global image immersion demo:
Blur background demo:
Dynamic blur demonstration:
Reverse dynamic blur demonstration
A single animation is done. Here are a few groups of composite animations
Ok, that’s all for now, because there are too many combos to do
Here’s a quick calculation:
(Displacement animation (3)* Zoom animation (2)* Transparent animation (2)* Rotation animation (6), image background effects (4)=288, in addition to zoom, transparency,3D rotation, dynamic blur can be set range, so more customizable effects.Copy the code
Next, it’s time to introduce how to use:
For testingDemo
On the demo of many effects, while the dynamic display of the current effect of the code to set the method, also contains some tips, suggest you first nextDemo
Take a look at first.Download the Demo
xml
Use method in layout file:
Copy the code
The layout file is very simple and contains twoxml
Layout, the top is the menu layout, the bottom is the content layout
This setting is sufficient for the simplest use, the default is fixed slide mode
If you want to customize the parameters and effects of a slide, look at the Settings in the resource file (all annotated and easy to understand)
Copy the code
The animation code is explained here
To facilitate the custom animation effects, use a 4 digits to represent different animation combination, bits represent the rotation of the animation sequence number, 10 representative transparency animation effects, one thousand delegates zoom animation effects, ten thousand delegates displacement animation effects, starting the locations are 1, there are several kinds of animation effects limit is how much. For example, there are three kinds of displacement animation, then the range of ten thousand bits is 1~3, and the others are followed by analogy.
Note: Because of the background, the blur effect will introduce extra components, so it is only added when needed, so it is not included in the animation code, the Settings will be explained below.
Stick a againxml
Implementation table of properties and code
Code implementation | XML realize | function |
---|---|---|
setStyleCode(int type) |
sm_type` | Sets the animation effect code |
setMenuOffset(int menuOffset) |
sm_menuoffset |
Sets the distance from the pull-out menu to the right border |
setDragWipeOffset(int dragWipeOffset) |
sm_dragoffset |
Set the range of trigger slides, 0 is full screen |
setStartScale(float minScale) |
sm_startscale |
Set initial zoom |
setStartAlpha(float startAlpha) |
sm_startalpha |
Set initial transparency |
setStart3DAngle(int start3DAngle) |
sm_start3dangle |
Set the starting 3D rotation Angle |
setFullColor(Activity activity, int headColor) |
There is no | Set global color |
setBackImage(Activity activity, int backBitmap, int headColor) |
There is no | Set the global image background and immerse |
setBlur(Activity activity, int backBitmap, int headColor, float blur) |
There is no | Sets the global blur background and specifies the degree of blur |
setChangedBlur(Activity activity, int backBitmap, int headColor) |
There is no | Set global dynamic blur (default range 0 to 25F) |
setReverseChangedBlur(Activity activity, int backBitmap, int headColor) |
There is no | Set reverse dynamic blur background (default range 0 to 25F) |
setChangedBlur(Activity activity, int backBitmap, int headColor, float startBlur, float endBlur) |
There is no | Sets dynamic blur for a specified range |
setOnMenuShowingListener(onSwipeProgressListener listener) |
There is no | Set slider listening, callback to get menu hidden to display progress, range (0~1.0f) |
changeAllColor(int color) |
There is no | Change global color (need to set global color first) |
isMenuShowing() |
There is no | Whether the current menu is displayed |
showMenu() |
There is no | According to the menu |
hideMenu() |
There is no | The hidden menu |
There are only so many methods provided, and it is not difficult to understand, but here are a few more caveats
1. No global background or color is set by default, so if you need global color immersion and background immersion, please make relevant Settings. Both types of immersion are compatible to 4.4
2. The global color supports dynamic change, but the global picture background is not supported. I thought there should be no such requirement, of course, you can give me feedback and I will add if there is.
3. Rotation animation is actually a 3D rotation effect is better, the other are added, if you want to use it together with the transparency animation, can prevent the stuck (single center rotation stuck obviously, after all, the cost of drawing is there)
I’m doing a demo just to make it easier for you to set it upDemo
Added the effect of the parameter Settings displayed inRecyclerView
One of the firstItem
, and can be changed dynamically, and the current effect needs to be set parameters are all shown above.
In addition withRecyclerView
Another purpose of the tooltip display is to demonstrate the handling of slide collisions. By default, both menus and contents can handle horizontal and vertical slides, and slides are triggered only when they are near the intersection of menu contents. Of course, you can also set the full screen slide and set the trigger range, the specific method to view the above table method, here will not repeat.
That’s it. Here’s how to add a dependency library:
Android Studio
Like any other library, in yourApp
thebuild.gradle
Within thedependencies
add
The compile 'com. Brioal: SwipeMenu: 1.0'Copy the code