他の人が言ったように、そしてチェイニーが彼の答えで言ったように、意図したとおりにしておくのがおそらく最善です。ただし、 はDrawerLayout
とはスタイルが異なりSlidingMenu
ます。GoogleSlidingPaneLayout
は、SlidingMenu のスタイルにより近いものも追加しました。
SlidingPaneLayout
結局、それは私が探していたものであったため、この方法でa を実装することになりました。(これは YouTube/ハングアウト アプリのスタイルでもあります)
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/left_pane"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</android.support.v4.widget.SlidingPaneLayout>
次に、アクションバーのホームボタンで開きます:
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action buttons
switch(item.getItemId()) {
case android.R.id.home:
if (mPaneLayout.isOpen())
mPaneLayout.closePane();
else
mPaneLayout.openPane();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
PanelSlideListener
その後、スライド/オープン/クローズ時に処理する を実装できます。
ナビゲーション ドロワーに関する Adam Powell のシリーズも読むことをお勧めします。パート 3 では、SlidingPaneLayout と Navigation Drawer の使用について説明します。
パート 1 - https://plus.google.com/+AdamWPowell/posts/2zi4DXd3jkm
パート 2 - https://plus.google.com/+AdamWPowell/posts/VdgexsZeXHW
パート 3 - https://plus.google.com/+AdamWPowell/posts/8j2GVw72i1E
パート 4 - https://plus.google.com/+AdamWPowell/posts/TtBFUXhe5HU