SlidingMenu README

The project's README from github.com/jfeinstein10/SlidingMenu. As one markdown file: README.md.

SlidingMenu (Play Store Demo)

SlidingMenu is an Open Source Android library that allows developers to easily create applications with sliding menus like those made popular in the Google+, YouTube, and Facebook apps. Feel free to use it all you want in your Android apps provided that you cite this project and include the license in your app.

SlidingMenu is currently used in some awesome Android apps. Here's a list of some of them:

If you are using SlidingMenu in your app and would like to be listed here, please let me know via Twitter!

Here's an older video of the example application in this repository : http://youtu.be/8vNaANLHw-c

Also, you can follow the project on Twitter : @SlidingMenu

Setup

Setup with ActionBarSherlock

How to Integrate this Library into Your Projects

In order to integrate SlidingMenu into your own projects you can do one of two things.

1. You can wrap your Activities in a SlidingMenu by constructing it programmatically (new SlidingMenu(Context context)) and then calling SlidingMenu.attachToActivity(Activity activity, SlidingMenu.SLIDING_WINDOW | SlidingMenu.SLIDING_CONTENT). SLIDING_WINDOW will include the Title/ActionBar in the content section of the SlidingMenu, while SLIDING_CONTENT does not. You can check it out in the example app AttachExample Activity.

2. You can embed the SlidingMenu at the Activity level by making your Activity extend SlidingActivity.

3. You can use the SlidingMenu view directly in your xml layouts or programmatically in your Java code.

Simple Example

public class SlidingExample extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTitle(R.string.attach);
		// set the content view
		setContentView(R.layout.content);
		// configure the SlidingMenu
		SlidingMenu menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
		menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		menu.setShadowWidthRes(R.dimen.shadow_width);
		menu.setShadowDrawable(R.drawable.shadow);
		menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
		menu.setFadeDegree(0.35f);
		menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
		menu.setMenu(R.layout.menu);
	}
    
}

XML Usage

If you decide to use SlidingMenu as a view, you can define it in your xml layouts like this:

<com.jeremyfeinstein.slidingmenu.lib.SlidingMenu
    xmlns:sliding="http://schemas.android.com/apk/res-auto"
    android:id="@+id/slidingmenulayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    sliding:viewAbove="@layout/YOUR_ABOVE_VIEW"
    sliding:viewBehind="@layout/YOUR_BEHIND_BEHIND"
    sliding:touchModeAbove="margin|fullscreen"
    sliding:behindOffset="@dimen/YOUR_OFFSET"
    sliding:behindWidth="@dimen/YOUR_WIDTH"
    sliding:behindScrollScale="@dimen/YOUR_SCALE"
    sliding:shadowDrawable="@drawable/YOUR_SHADOW"
    sliding:shadowWidth="@dimen/YOUR_SHADOW_WIDTH"
    sliding:fadeEnabled="true|false"
    sliding:fadeDegree="float"
    sliding:selectorEnabled="true|false"
    sliding:selectorDrawable="@drawable/YOUR_SELECTOR"/>

NOTE : you cannot use both behindOffset and behindWidth. You will get an exception if you try.

Caveats

Developed By

License

Copyright 2012-2014 Jeremy Feinstein

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

SlidingMenu (jfeinstein10/SlidingMenu)

Searching Database…

这是什么?一个开源的 Android 库,用于实现侧滑导航菜单——就是 Google+、YouTube 和 Facebook 应用带火的那种交互模式。你可以把它嵌入自己的 Android 应用里。
菜单打开时我看到的是什么?屏幕分成两层:上层视图(你的内容)和下层视图(菜单)。打开菜单时,上层视图滑到一边,露出下层视图。下层视图通过 setBehindContentView 或 viewBehind 来设置。
怎么把它加到我的 Android 项目里?在 Eclipse 中把 SlidingMenu 作为 Android 库项目导入,运行 Project > Clean 生成 R.java 等资源文件,然后把它添加为你现有项目的依赖。
它能和 ActionBarSherlock 一起用吗?可以。先把 ActionBarSherlock 作为依赖加到 SlidingMenu,然后让你用到的 SlidingActivity 改为继承 Sherlock 系列的 Activity,而不是普通的 Activity。
有什么坑需要提前知道?behindOffset 和 behindWidth 不能同时设置,两个都设会抛异常。另外你的布局必须基于 viewgroup,README 也承认这会牺牲一些优化。
它真的经过实际验证吗,还是个人实验项目?经过大规模验证:README 列出了使用它的应用,包括 Foursquare、LinkedIn、Rdio、Evernote Food、VLC for Android、9GAG、Wunderlist 2 和 The Verge。
我能把它放进自己的应用发布吗?需要署名吗?可以。它采用 Apache 2.0 协议,可以自由使用,但作者有一个请求:在你的应用中注明出处并附上许可证。
SLIDINGWINDOW 和 SLIDINGCONTENT 有什么区别?这是 attachToActivity 的两种模式:SLIDINGWINDOW 会把标题栏/ActionBar 也纳入滑动部分,而 SLIDINGCONTENT 则不包含它。
touchModeAbove 改变的是什么?它决定上层视图显示时屏幕哪些区域可以响应触摸:'margin' 表示只有左侧边缘能打开菜单,'fullscreen' 表示整个屏幕都可以。默认是 margin。
selector 高亮效果在 ListView 的列表项上能用吗?多半不行。你必须对选中的视图调用 setSelectedView,而且 README 提醒说,由于 Android 会回收复用列表项视图,它很可能无法作用于 ListView 中的列表项。
Size
31.3 MB
Stars
11K
Updated
CommitMar 09
Age
14y
Commits · 90 Days