2013-02-25 31 views
1

我正在構建一個應用程序,其中有一個GridView結果項目顯示在屏幕上。 當用戶點擊其中一個項目時,結果片段被推到側面並顯示一個細節片段。我已經使用了來自Complete Working Sample of the Gmail Three-Fragment Animation Scenario?的CommonsGuy實現(https://github.com/commonsguy/cw-omnibus/tree/master/Animation/ThreePane)。GridView 3列之間的動畫/ GridView 1列

enter image description here

這工作都好,唯一的事情是,我設置了網格佈局的結果片段從3列1列時推動他們離開,這不看耐克可能會混淆用戶。我怎麼能讓這個過渡動畫?

回答

1

試試這個代碼

Fragment newFragment; 
newFragment=new one_defalut(); 
FragmentTransaction transation=getFragmentManager().beginTransaction(); 
transation.setCustomAnimations(R.anim.slide_in_right, 0); 
transation.replace(R.id.myfragment, newFragment); 
transation.addToBackStack(null); 
        //transation.setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE); 

transation.commit(); 

代碼slide_in_right.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android" 
    android:propertyName="x" 
    android:valueType="floatType" 
    android:valueFrom="1280" 
    android:valueTo="0" 
    android:duration="300"/> 
</set>