-2

請任何人建議我如何實現導航抽屜滑動完成屏幕的活動。如何實現可以滑動整個活動內容的Android導航抽屜?

enter image description here

OR

enter image description here

在此先感謝。

*** ---------

解決方案

-------- *:** 我發現這個解決方案。

使用此lib中很容易使用和處理

https://github.com/adamrocker/simple-side-drawer

+0

看看這個:http://stackoverflow.com/questions/37451594/slidingpanellayout-not-work-well-from-right-to-left-in-android/37452561#37452561在我的答案我已打開面板上'按鈕'點擊。你已經寫了'ToggleButton'點擊。 – Ironman

+0

嗨在這個例如Actionbar不是slide.how來處理這個?我想Actionbar幻燈片 – SAndroidD

+0

訪問此:http://stackoverflow.com/questions/11234375/how-did-google-manage-to-do-this-slide-actionbar-in-android-application – Ironman

回答

0

您可以嘗試使用此佈局抽屜活動。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:elevation="7dp" 
    > 

    <RelativeLayout 
     android:id="@+id/content_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 

    </RelativeLayout> 

    <FrameLayout 
     android:id="@+id/drawer_holder" 
     android:layout_width="@dimen/drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     > 

     <ListView 
      android:id="@+id/drawer_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      /> 

    </FrameLayout> 

</android.support.v4.widget.DrawerLayout> 

並將DrawerLayout.DrawerListener加到DrawerLayout這樣。

drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() { 
      @Override 
      public void onDrawerSlide(View view, float slideOffset) { 
       drawerView.setX(drawerHolder.getWidth() * (1 - slideOffset)); 
       contentLayout.setX(drawerHolder.getWidth() * slideOffset); 
      } 

      @Override 
      public void onDrawerOpened(View view) { 
      } 

      @Override 
      public void onDrawerClosed(View view) { 
      } 

      @Override 
      public void onDrawerStateChanged(int newState) { 
      } 
     }); 

並添加listner後把這個代碼。

drawerLayout.closeDrawer(drawerHolder); 
mainDrawerView.setX(0); 
contentLayout.setX(0); 

希望這會有所幫助。