如何在android中动画启动画面

时间:2013-06-11 12:09:50

标签: android splash-screen

我是android新手。我想在android中动画启动画面。 任何链接或示例代码都将被接受。

public class OneActivity extends Activity
{
    @Override
    protected void onCreate( Bundle savedInstanceState )
    {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.one );
        ((Button)findViewById( R.id.next_button )).setOnClickListener( new OnClickListener()
        {
            @Override
            public void onClick( View v )
            {
                startActivity( new Intent( OneActivity.this, TwoActivity.class ) );
                overridePendingTransition( R.anim.slide_in_left, R.anim.slide_out_left );
            }
        });
    }
}

slide_in_left.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="100%p" android:toXDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

slide_out_left.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime" />

还有其他方式吗???或者不使用XML ..! 谢谢。

1 个答案:

答案 0 :(得分:0)

slape.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <!-- <scale
        android:duration="2000"
        android:fillBefore="false"
        android:fromXScale="0.0"
        android:fromYScale="0.0"
        android:toXScale="1.0"
        android:toYScale="1.0" />

    <translate
        android:duration="2000"
        android:fromXDelta="-200"
        android:fromYDelta="-200" /> -->
        <scale android:fromXScale="1"
        android:fromYScale="1"
        android:toXScale="1.0"
        android:toYScale="1.0"
        android:duration="1000"/>
    <translate
        android:fromXDelta="200"
        android:fromYDelta="200"
        android:toXDelta="0"
        android:toYDelta="0"
        android:duration="1000"/>

</set>

在活动中:

ImageView imgMain = (ImageView) findViewById(R.id.imgMain);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.slape);
        imgMain.startAnimation(animation);

new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                    runOnUiThread(new Runnable() {
                     public void run() {

                     }
                });
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }).start();