Android Push-up menu, two views are displayed on the same screen within the same layout.

Source: Internet
Author: User

Recently in a Baidu map to write a small application, after all, the screen is so big, to put a few buttons on top, how the layout is ugly. Baidu a bit, found that the side-slide menu is good, Baidu map is to use the hand slippery Ah, your sister, these two things actually also conflict, I bought a watch last year. So, think of the push menu, can not use the slide screen to handle, then use a button to stimulate the push event bar. Because it is a novice what jb things do not understand, ask the group of big, say with translation animation, I also Baidu a half-day a look TM too tall on, with bad. Accidentally found in a piece of code

Linearlayout.layoutparams LP = new Linearlayout.layoutparams (LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

Lp.setmargins (0, 0, 0, 0);

MENU.SETLAYOUTPARAMS (LP);

This thing, carefully pondering a night, finally is to achieve my needs, words not to say, put code, is a small breakthrough, put blog to remember.




First create a layout file that contains two linealayout, which is the main view and menu views used above


The next step is to implement the function.



do not know how many people use this method, anyway, I found on the internet for a large half-day has not realized this function, the individual think is the simplest, most understandable push menu.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.