2015-06-21 103 views
0

我想实现导航抽屉没有ActionBar如何使导航抽屉没有操作栏

enter image description here

有一个小的布局,它里面有一个按钮。 点击按钮后,导航抽屉会打开。导航抽屉将在按钮下方。 我如何在android中实现这个?

+1

可能重复:// stackoverflow.com/questions/30961326/navigation-drawer-without-actionbar-android) –

回答

0

定义你这样的XML和你做

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="100dp" // static height for view or keep it dimen.xml 
     android:background="#21ef70" 
     android:gravity="bottom" 
     android:orientation="horizontal"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Click" 
      android:id="@+id/button2" /> 
    </LinearLayout> 
</LinearLayout> 

<!-- Listview to display navigation menu --> 
<ListView 
    android:id="@+id/list_slidermenu" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:layout_marginTop="100dp" // same margin as of layout 
    android:choiceMode="singleChoice" 
    android:dividerHeight="1dp" /> 
</android.support.v4.widget.DrawerLayout> 
+0

如果你想要它在绿色布局下,只需填充到列表和透明背景。 –

+0

@StephaneMathis嘿我已经从顶部给列表视图保证金? –

+0

看到这个链接http://stackoverflow.com/questions/30961326/navigation-drawer-without-actionbar-android/30961388?noredirect=1#comment49955090_30961388 –

0

要隐藏动作条,简单地做到这一点:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    getSupportActionBar().hide(); 
} 
[抽屉式导航无动作条,机器人(HTTP的