Ivan
Ivan

Reputation: 41

Programmatically hide the handle of a sliding drawer

Is there a way on how I could hide the handle of a sliding drawer upon opening the sliding drawer? I've tried using the setVisibility(View.GONE) method when the OnDrawerOpenListener was triggered, but the handle is still visible. Is it possible to hide the handle of the drawer or it would always be visible? Here's a snippet of the xml of my sliding drawer:

        <SlidingDrawer android:layout_width="wrap_content"
        android:id="@+id/notifDrawer" android:handle="@+id/notifHandle"
        android:content="@+id/notifContent" android:layout_height="fill_parent"
        android:orientation="horizontal">
        <LinearLayout android:id="@+id/notifHandle"
            android:layout_width="wrap_content" android:layout_height="fill_parent"
            android:background="@drawable/button_selected" android:orientation="vertical"
            android:padding="0dip" android:gravity="center">
            <TextView android:id="@+id/notification_count"
                android:visibility="gone" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:textSize="10sp"
                android:textStyle="bold" android:textColor="#FFFFFF"
                android:gravity="center" android:background="@drawable/badge">
            </TextView>
        </LinearLayout>
        <ListView android:id="@+id/notifContent"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:background="#C0C0C0" android:divider="@drawable/divider"
            android:fadingEdge="none">
        </ListView>
    </SlidingDrawer>

Upvotes: 4

Views: 3884

Answers (4)

mark.kedzierski
mark.kedzierski

Reputation: 663

I created a complete replacement for Google's SlidingDrawer widget. http://www.github.com/kedzie/DraggableDrawers It allows drawers without handles (which are opened programmatically) or simple calling drawer.getHandle().setVisibility(GONE);

Upvotes: 0

Velizar Hristov
Velizar Hristov

Reputation: 710

What I did is to set the image of the handle ImageButton to the first 300x1 or so pixels of the background, so that it adds an additional line at the bottom that isn't noticeable.

Upvotes: 0

Samrakchan
Samrakchan

Reputation: 370

Following trick worked for me

    <Button
      android:id="@+id/handle"
      android:layout_width="0dp"
      android:layout_height="0dp"
      android:background="#00000000" />

Upvotes: 3

gilsaints88
gilsaints88

Reputation: 21

What I did is below to be able to hide the handle:

<LinearLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:gravity="bottom"
        android:orientation="vertical">
        <SlidingDrawer android:layout_width="fill_parent"
            android:id="@+id/drawerShare" android:handle="@+id/slideHandleButton2"
            android:content="@+id/contentLayout" android:layout_height="fill_paren`enter code here`t"
            android:orientation="horizontal">

            <Button android:layout_width="0px" android:layout_height="0px"
                android:id="@+id/slideHandleButton2">
            </Button>
....

I set the layout_width and layout_height of the button that is defined as my handle to 0px. Hope this helps.

Upvotes: 2

Related Questions