Fragment從上到下進入效果

weixin_34320159發表於2016-08-21

新增Fragment的入場動畫

public void replaceFragment(Fragment fragment) { 
   FragmentManager fragmentManager = getSupportFragmentManager();
   FragmentTransaction transaction = fragmentManager.beginTransaction();    
   //新增Fragment的進入動畫  
transaction.setCustomAnimations(R.anim.anim_sild_down,0,R.anim.anim_sild_down,0)
.replace(R.id.frag_container, fragment) 
.commit();}

R.anim.anim_sild_down

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/linear" 
android:duration="1000" > 
 <translate        
   android:fromYDelta="100%p"      
   android:startOffset="0"     
   android:toYDelta="0" /> 
   <scale 
   android:fromXScale="0.0"       
   android:toXScale="0.8"        
   android:fromYScale="0.0"      
   android:toYScale="0.8"     
   android:pivotX="50%"        
   android:pivotY="50%"     
   android:startOffset="0"        />
</set>

相關文章