Android uses drawerlayout to imitate the side sliding effect of qq6.6

When it comes to the sideslip menu, I believe everyone will think of an open-source control slidingmenu. When Google hasn't come out of drawerlayout, it almost uses slidingmenu to achieve the sideslip effect. It can be said that the effect is very good. Since Google came out of drawerlayout, many companies have used drawerlayout, such as didi taxi and so on. So today we use the drawer layout to achieve the latest side sliding effect of qq6.6. First, let's take a look at the default effect of drawerlayout:

It is still different from the sideslip of the latest version of QQ. The difference is that the content page does not slide to the right, but the menu directly covers the content. Let's take a look at a QQ style map

In this way, you can see the difference. In fact, we just need to let the content page follow the sliding when sliding the left menu. First, let's see if drawerlayout gives us the monitoring of sliding. Ha ha, after turning to the source code, we found this method ondrawersize method; Just implement the setdrawerlistener callback. The code is as follows:

Then look at the effect of our change:

Is it so interesting? Ha ha, that's all for today.

Finally, the source code is attached: https://github.com/dalong982242260/DrawLayoutMenu

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>