Use of Android SlidingMenu

Sometimes we find that the mobile phone can slide left and right to display different interfaces, which is called the side sliding effect. How is this effect achieved? Here we will use the open source control - SlidingMenu. SlidingMenu can achieve this effect very well. Let's combine Demo to realize the explanation. First, let's take a look at the renderings of Demo:
write picture description here
write picture description here

We need to download the open source package of SlidingMenu. There are three ways to use it in combination with your project. The first way is: import the SlidingMenu open source package as a dependency library into your project; the second way is: get the open source package The related classes in , and then Copy to your own project; the third way is to use the SlidingMenu.jar package, but if you use this directly, it will report a related ClassNotFound error, this is because SlidingMenu also relies on another ActionBarSherLock.jar package, two If used in combination, no error will be reported.

Then we look at the main code snippet of SlidingMenu in Activity:

SlidingMenu menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT_RIGHT);
// 侧滑菜单的布局
menu.setMenu(R.layout.left_menu);
menu.setSecondaryMenu(R.layout.right_menu);

menu.setBehindOffset(200);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);

// 设置触摸模式
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);

// 设置渐入渐出效果的值
menu.setFadeDegree(0.35f);

Of course, the layout used by this demo is very simple. Generally, SlidingMenu will be used in combination with Fragment, which makes the interface layout very flexible.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325874607&siteId=291194637