Android custom view imitation QQ sideslip menu implementation code
First look at the side sliding effect of QQ
Analyze it
First go to the schematic diagram (I don't know if it can be expressed clearly = =)
-Firstly, the horizontal scroll view of Android is used as the container. Of course, we need to inherit it and customize a side slide view
-There is a parent layout in this container (generally linerlayout, which is used in this demo). There are and only two child controls (layout) in this parent layout. The position of the menu page in the initial state is offset on the Y axis, so that the visual effect of the home page superimposed on the menu page can be formed; Then, in the process of sliding, the offset is gradually corrected, and finally the menu page and the home page are arranged side by side. When the principle is clear, it's not a matter to realize
Concrete implementation
Layout code
Custom sideslip view
The core part
extend
The added definition attribute allows the user to configure the value of the margin from the menu to the right; First, create a new attr.xml in the values folder and write the following:
Set margins in layout
I won't repeat anything else. Let's see the effect
-Download demo source code click download
summary
The above is the implementation code of Android custom view imitating QQ sideslip menu introduced by Xiaobian. I hope it will help 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!