Is it possible to use something other than a listview as sliding drawer in drawerlayout

This will work if you move both the android:id=”@+id/left_drawer” (or create a new id) and set the gravity. The id move (or new one) is so the reference is correct so you call closeDrawer() on it and not the child views. But most importantly, the DrawerLayout requires that element to have a android:layout_gravity set on … Read more

ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams

What solved this issue for me: In MainActivity, add a new field for the LinearLayout, and assign value to it in onCreate() (this part just like emaleavil suggested): private LinearLayout linearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // … linearLayout = (LinearLayout) findViewById(R.id.linearLayout); } Then in selectItem(), when calling closeDrawer(), simply pass linearLayout as … Read more

Full width Navigation Drawer

If you want simpler solution you can just set negative margin android:layout_marginLeft=”-64dp” for your left_drawer: <include android:id=”@+id/left_drawer” android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_gravity=”start” layout=”@layout/drawer” android:layout_marginLeft=”-64dp”/>

How to open Navigation Drawer with no actionbar, open with just a button

It’s giving you a null pointer because you are trying to find the drawer layout in the fragment’s view, when it is actually in the activities view. A quick hack to do what you want is to find the view like: getActivity().findViewById(R.id.drawer_layout) That should work. A better way is to have a method on the … Read more

Android: How do I keep DrawerLayout from passing touch events to the underlying view

Set clickable to true on the drawer – it’ll consume the touch. <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”> <FrameLayout android:id=”@+id/content_view” android:layout_width=”wrap_content” android:layout_height=”wrap_content”/> <FrameLayout android:id=”@+id/drawer_view” android:layout_width=”300dp” android:clickable=”true” android:importantForAccessibility=”no” android:layout_height=”match_parent” android:layout_gravity=”left”/> </android.support.v4.widget.DrawerLayout> I added android:importantForAccessibility=”no” because marking the drawer as interactive (clickable or focusable) will make the entire drawer visible to accessibility services like TalkBack. This is not … Read more