Question

What I want is to show the bar that is hidden on the left, when a user enters a layout, the idea is that you know that there is that bar without having to put an icon on the actionbar that signal its existence

Was it helpful?

Solution

If you want to open the navigationdrawer the first time the activity is created you can simply do something like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer_activity);

    drawer = (ListView) findViewById(R.id.left_drawer); // the drawer itself (ListView for example)
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // the drawer layout itself

    drawerLayout.openDrawer(drawer);
}

Your xml may look something like this:

<?xml version="1.0" encoding="utf-8"?>

<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"
    android:background="?attr/background_activity_color">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/fragmentFrame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->
    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="250dp"
        android:layout_height="match_parent" />
</android.support.v4.widget.DrawerLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top