8

My problem:

I want to add draggable icon in navigation drawer.

This icon combined with listview of navigation drawer when drawer open.

see similar like this,

enter image description here

What I have tried,

I searched in StackOverflow like similar question this,

Draggable drawer with a handle (instead of action bar) on top of other apps

But all answer suggest to 3rd party library.

My question

1.It`s possible to add draggable icon with navigation drawer?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159
  • I want similar dragable navigation drawer only..not coc:) – Ranjithkumar Jan 29 '16 at 11:52
  • 2
    As far as I can tell looking at the DrawerLayout source code it cannot behave exactly as you want it to. (https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/widget/DrawerLayout.java) So either you have to use a library, or you should subclass DrawerLayout and create your own ViewDragHelper that behaves like you want it to behave. (to understand the principle, look here:http://flavienlaurent.com/blog/2013/08/28/each-navigation-drawer-hides-a-viewdraghelper/) – Jeroen Mols Feb 04 '16 at 08:16
  • really thanks @jmols.. I will try this. – Ranjithkumar Feb 04 '16 at 09:16
  • 1
    Good luck with that! Let me know if you can get it to work. – Jeroen Mols Feb 04 '16 at 09:26
  • Do you want just that icon to be there instead of the default hamburger icon? And on click of that you open and close the drawer ? – mike20132013 Feb 05 '16 at 17:33
  • @mike20132013 yes..But icon combine with drawer open & close. – Ranjithkumar Feb 06 '16 at 04:22
  • You can toggle the on and off of drawer with that icon placed there using toolbar as ur top bar and adding a custom view as ur toolbar layout – mike20132013 Feb 07 '16 at 07:26

1 Answers1

3

For drag layout there is github library which is useful for it
You can drag from left to right or any where. It will also slide from left to right & also drag is also possible.Drag Layout link

    <RelativeLayout
            android:id="@id/left_big_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FF00FFFF">
        <TextView android:text="LEFT"
                  android:layout_centerInParent="true"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"/>
    </RelativeLayout>

    <ImageView android:id="@id/left_big_handle"
               android:background="@drawable/handle"
               android:layout_gravity="top"
               android:layout_marginTop="12dp"
               android:layout_width="24dp"
               android:layout_height="80dp"/>
</com.kedzie.drawer.DraggedDrawer>

handle.xml drawable file of handle

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

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true" android:drawable="@drawable/status_bar_close_red" />

    <item android:drawable="@drawable/status_bar_close_off" />

</selector>

ScreenShot

enter image description here

Hope this is useFul for you.

Maheshwar Ligade
  • 6,709
  • 4
  • 42
  • 59