所以事實證明,這是可能的使用SlidingMenu。基本上我結束了創建兩個SliderMenu對象:
public class SlidingMenuEvernoteActivity extends SlidingFragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sliding_menu_main);
setBehindContentView(R.layout.sliding_menu_red);
setSlidingActionBarEnabled(false);
SlidingMenu leftMenu = getSlidingMenu();
leftMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
leftMenu.setMode(SlidingMenu.LEFT);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.sliding_menu_main, new ListFragment())
.commit();
SlidingMenu rightMenu = new SlidingMenu(this);
rightMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
rightMenu.setMode(SlidingMenu.RIGHT);
rightMenu.setMenu(R.layout.sliding_menu_blue);
rightMenu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.sliding_menu_blue, new ListFragment())
.commit();
}
}
注:由於活動延伸SlidingFragmentActivity,沒有必要創建兩個SlidingMenu手動對象。第一個是在回調中自動創建的。
這裏是相關佈局文件:
* sliding_menu_main.xml *
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:clickable="true"
android:id="@+id/sliding_menu_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/textView"
android:layout_gravity="center" />
</FrameLayout>
* sliding_menu_red.xml *
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_menu_red"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff001c">
</LinearLayout>
* sliding_menu_blue.xml *
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_menu_blue"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0028ff">
</LinearLayout>
有趣。我沒有考慮使用SlidingPaneLayout。感謝您的建議 – kierse