2011-12-01 22 views
6

Próbuję dostosować moje przejścia FragmentTransaction i natknąłem się na metodę setTransitionStyle. Przyjmuje identyfikator zasobu xml dla stylu, ale nie mam pojęcia, jak będzie wyglądał zasób xml. Wiem, że możesz definiować style animacji dla działań i zakładam, że xml potrzebny dla tej metody jest podobny, ale nie mogę znaleźć żadnej dokumentacji o wymaganym formacie (np. Xml atrybuty/węzły potrzebne do tego działania).Android FragmentTransaction setTransitionStyle

Edit1 (to, co robię teraz w moim FragmentActivity):

public void pushFolderFrag(Fragment folderFrag, String backStackID) { 
    FragmentTransaction transaction = getFragmentManager().beginTransaction(); 
    transaction.replace(R.id.SplitView_MasterContainer, folderFrag); 
    transaction.addToBackStack(backStackID); 
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); 
    //transaction.setTransitionStyle(arg0);//what does the format for this resource look like?? 

    // Commit the transaction 
    transaction.commit(); 
} 
+1

Zajmuje obiekt animacji, choć nie jest wyjaśnij co (nie zagłębiłem się wystarczająco głęboko w źródło Androida). Następujące działa, ale nie zrobił nic: 'transaction.setTransitionStyle (android.R.attr.fragmentFadeExitAnimation);' – scorpiodawg

Odpowiedz

1

Znalazłem odpowiedź na ten link

https://github.com/kedzie/Support_v4_NineOldAndroids

styl przejścia zasobów

Określ animacje przejścia w zasobie stylu.

Tworzenie `styl zasobów RES/wartości/styles.xml”

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <!-- Override standard Transitions with a Style --> 
    <style name="MyTransitionStyle"> 
     <item name="fragmentFadeEnterAnimation">@animator/fade_enter</item> 
     <item name="fragmentFadeExitAnimation">@animator/fade_exit</item> 
     <item name="fragmentOpenEnterAnimation">@animator/flip_left_in</item> 
     <item name="fragmentOpenExitAnimation">@animator/flip_left_out</item> 
     <item name="fragmentCloseEnterAnimation">@animator/flip_right_in</item> 
     <item name="fragmentCloseExitAnimation">@animator/flip_right_out</item> 
    </style> 
</resources> 

Określanie zasobów i przejście w transakcji

tx.setTransitionStyle(R.style.MyTransitionStyle); 
tx.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 
Powiązane problemy