2016-02-17 23 views
9

Zróbmy coś trudnego. Widziałem tę animację do nawigacji Szuflada: enter image description hereWłasna animacja do szuflady nawigacji otwiera się i zamyka

i chciałbym to wdrożyć, ponieważ jest to świetny efekt. Próbowałem uzyskać efekt, tworząc niestandardowy widok i po dotyku uzyskuję co najmniej 50% podobny efekt. Chciałbym wdrożyć moje metody ondraw() i ontouch() z mojego niestandardowego widoku do widoku nawigacji. Jak to się robi? Ktoś ma jakąś wskazówkę? Czy ktoś może dać dowolny link, który ma simlar rzeczy.

Próbowałem to:

public class CustomNavigation extends DrawerLayout { 

    public CustomNavigation(Context context) { 
     super(context); 
    } 

    public CustomNavigation(Context context, AttributeSet attrs) { 
     super(context, attrs); 
    } 

    public CustomNavigation(Context context, AttributeSet attrs, int defStyleAttr) { 
     super(context, attrs, defStyleAttr); 
//  invalidate(); 
    } 
    public void start() 
    { 
     this.invalidate(); 
     Log.d("Parth", "start"); 
    } 

    @Override 
    public void onDraw(Canvas c) { 
     Log.d("Parth", "ondraw"); 
//  super.onDraw(c); 

    } 

} 

Kontrole na metodzie draw nie jest tzw. dlaczego to jest takie?

od głównej działalności i tworzenia obiektu klasy powyżej wywołać metodę startu takiego:

CustomNavigation drawer = (CustomNavigation) findViewById(R.id.drawer_layout); 
drawer.start(); 

a to dopiero początkowa rzeczy, ja też chcą wprowadzić te:

+0

Witam, mam pomysł, jak osiągnąć, kliknij element widoku listy i otwórz animację strony szczegółów, jak na powyższym zdjęciu, Pomoc doceniona Dzięki z góry – KeTaN

Odpowiedz

5

W końcu po znalezieniu tak dużo znalazłem bibliotekę do tego, a tutaj jest link do niego. Nie wiem, dlaczego tak trudno było znaleźć. Albo to był tylko mój zły tydzień, tak czy inaczej dla tych, którzy chcą z niego skorzystać, znajdziesz tu bibliotekę. i więcej w ciągu Ja też dać wdrożenie jeśli jest to potrzebne:

main_activity.xml

<?xml version="1.0" encoding="utf-8"?> 
<com.mxn.soul.flowingdrawer_core.LeftDrawerLayout 
    android:id="@+id/id_drawerlayout" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clipChildren="false" 

    > 

    <!--content--> 
    <android.support.design.widget.CoordinatorLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
    </android.support.design.widget.CoordinatorLayout> 

    <!--menu--> 
    <RelativeLayout 
     android:layout_width="280dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:clipChildren="false" 
     > 
     <com.mxn.soul.flowingdrawer_core.FlowingView 
      android:paddingRight="35dp" 
      android:id="@+id/sv" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
     <FrameLayout 
      android:id="@+id/id_container_menu" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_marginRight="25dp" 

      /> 
    </RelativeLayout> 

</com.mxn.soul.flowingdrawer_core.LeftDrawerLayout> 

Main_activity.java

public class MainActivity extends AppCompatActivity{ 

    private LeftDrawerLayout mLeftDrawerLayout; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     mLeftDrawerLayout = (LeftDrawerLayout) findViewById(R.id.id_drawerlayout); 

     FragmentManager fm = getSupportFragmentManager(); 
     MyMenuFragment mMenuFragment = (MyMenuFragment) fm.findFragmentById(R.id.id_container_menu); 
     FlowingView mFlowingView = (FlowingView) findViewById(R.id.sv); 
     if (mMenuFragment == null) { 
      fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment = new MyMenuFragment()).commit(); 
     } 
     mLeftDrawerLayout.setFluidView(mFlowingView); 
     mLeftDrawerLayout.setMenuFragment(mMenuFragment); 
    } 


} 

teraz navigationview jest uważany jako fragment tutaj tak kod ten fragment jest tutaj:

public class MyMenuFragment extends MenuFragment{ 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View v = inflater.inflate(R.layout.fragment,container,false); 

     return setupReveal(v); 
    } 
} 

To wszystko. Możesz podziękować this person za wspaniałą pracę.

+0

Nie uruchamiam ... pokazując mi ten błąd . java.lang.RuntimeException: Nie można rozpocząć działania ComponentInfo {com.mxn.soul.flowingdrawer/com.mxn.soul.flowingdrawer.MainActivity}: java.lang.IllegalArgumentException: Target nie może mieć wartości NULL. – Debasish

+0

Powodowane przez: java.lang.IllegalArgumentException: Target nie może mieć wartości null. na com.squareup.picasso.RequestCreator.into (RequestCreator.java:607) na com.squareup.picasso.RequestCreator.into (RequestCreator.java:590) na com.mxn.soul.flowingdrawer.MenuListFragment.setupHeader (MenuListFragment.java:58) at com.mxn.soul.flowingdrawer.MenuListFragment.onCreateView (MenuListFragment.java:45) – Debasish

1

wiotki animacja

Można przyjąć pomoc z tego LINK

enter image description here enter image description here

przykładem wideo z tej biblioteki na tej youtube video.

The demo app można znaleźć w sklepie z zabawkami.

+0

ohk dziękuję, źle spróbuj tego –

Powiązane problemy