Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've created my own solution for this as well, as many stock solutions appeared to not work on older Android version or lacked proper instructions on how to get it to work.</p> <p>My solution has the following features:</p> <ul> <li>Provides support for sliding away a view to reveal a menu that lies underneath it</li> <li>The menu can be any custom View</li> <li>The view above can be any custom View as well</li> <li>Supported on old Android versions (tested to work at least on Android 2.2)</li> </ul> <p>The solution uses a custom layout, called <code>SlidingMenuLayout</code>, that you are expected to add 2 views to. The first view you add is the menu, the second is the main view.</p> <p>The simplest way to add the layout to your existing project is to override your Activity's <code>setContentView()</code> method:</p> <pre><code>@Override public void setContentView(View view) { SlidingMenuLayout layout = new SlidingMenuLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); layout.addView(new MenuView(this)); layout.addView(view); super.setContentView(layout); } </code></pre> <p>In this example, MenuView is the view that will actually show the menu. It is up to you to implement this view.</p> <p>Finally, you can add a button (typically in the top left corner of your main view), that calls <code>openMenu()</code> or <code>closeMenu()</code> on the layout as appropriate.</p> <p>The code for <code>SlidingMenuLayout</code> is found on the GitHub project <a href="https://github.com/arendjr/SlidingMenuLayout" rel="nofollow">page</a>: </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload