Android - 动画 - 位移 - XML

Android 实现的位移动画- XML

 

1 sdk level 11 以下

<?xml version="1.0"encoding="utf-8"?>

<setxmlns:android="http://schemas.android.com/apk/res/android" >

 

   <translate

       android:duration="300"

       android:fromYDelta="100%p"

       android:toYDelta="0" />

 

</set>

 

2 sdk level 11 及以上

<?xml version="1.0"encoding="utf-8"?>

<objectAnimatorxmlns:android="http://schemas.android.com/apk/res/android"

    android:interpolator="@android:interpolator/accelerate_decelerate"

   android:valueFrom="1920"

   android:valueTo="0"

   android:valueType="floatType"

   android:propertyName="Y"

   android:duration="1000" />

 

3 启动 Activity

/**

          * start im activity

          */

         privatevoid startIMActivity() {

                   Intent_i = new Intent(this, IMActivity.class);

                   //startActivity(_i);

                   startActivityForResult(_i,IMActivity.IM_ACTIVITY_REQ);

                   overridePendingTransition(R.anim.slide_bottom_in,android.R.anim.fade_out);

         }

 

4 Fragment 转场

FragmentManager _fragmentManager;

                            FragmentTransaction_fragmentTransaction;

                            _fragmentManager= getSupportFragmentManager();

                            _fragmentTransaction= _fragmentManager.beginTransaction();

                            _fragmentTransaction.setCustomAnimations(R.anim.slide_bottom_in_imfragment,R.anim.slide_top_out_imfragment);

                            _fragmentTransaction.commit();

展开阅读全文

没有更多推荐了,返回首页