Everyone client has a special effect is still very attractive, the main interface fingers slide right, you can show the menu, and the main screen will be hidden most, but still a small part of the left side with the menu to display.
It is said that this special effect is copied from Facebook clients, and it is not known whether Facebook has copied it from elsewhere. OK, today we will work together to achieve this effect, anyway, I first saw this special effect is in the client to see, I also subjectively think I am in imitation of the special effects of everyone client.
Although the implementation of the online similar effect is very much, but I found that the implementation of the solution is very complex, not easy to understand. But in fact this effect is not difficult to achieve, so I bring you today is also the history of the simplest sliding menu implementation scheme.
First, let's talk about the principle of implementation. There are two parts in the layout of an activity, one is the layout of the menu, the other is the layout of content. Two layouts are arranged horizontally, the menu layout is on the left, and the content layout is on the right. When initialized, the menu layout is shifted to the left so that it is completely hidden so that the content layout is fully displayed in the activity. Then, by listening to the finger sliding events, the left offset distance of the menu layout is changed to control the display and hiding of the menu layout. The schematic diagram is as follows:
Change the left offset value of the menu layout to 0 o'clock and the effect is as follows: