7

我的問題:如何添加導航抽屜可拖動圖標

我想在抽屜式導航添加可拖動圖標。

抽屜打開時,此圖標與導航抽屜的列表視圖組合。

看到這樣類似的,

enter image description here

我都試過了,

我搜索在StackOverflow上像類似的問題這一點,

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

但所有的答案建議第三方圖書館。

我的問題

1.It`s可以添加導航抽屜可拖動圖標?

+0

我想要類似的可拖動導航抽屜only..not coc :) –

+2

據我可以告訴看到DrawerLayout源代碼它不能完全按照你想要的。 (https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/widget/DrawerLayout.java)所以要麼你必須使用一個庫,或者你應該子類化DrawerLayout並創建你自己的ViewDragHelper,它的行爲就像你想要的那樣。 (瞭解原理,看看這裏:http://flavienlaurent.com/blog/2013/08/28/each-navigation-drawer-hides-a-viewdraghelper/) –

+0

真的很感謝@jmols ..我會試試這個。 –

回答

3

對於drag layout的GitHub庫
您可以從左至右或任何地方拖動這是有用的。它也會從左向右滑動&也拖動也是可以的。 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手柄提拉文件

<?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> 

截圖

enter image description here

希望這對你有用。

+0

是的..我的問題解決了..感謝 –

+0

很高興幫助你@Ranjith –