开发者

Programmatically hide the handle of a sliding drawer

开发者 https://www.devze.com 2023-04-01 20:57 出处:网络
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 wa

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>


Following trick worked for me

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


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.


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.


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);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号