欢迎界面效果

     大多数APP的欢迎界面是静态的,因为大多数欢迎界面除了准备APP的数据外,就是为了突出展示一点或者几点内容,内容展示清楚,使命也就完成了,也没必要去做动态的,做动态有点画蛇添足的感觉。但事情总有例外,比如像知乎的欢迎界面,就是一个动态的,尤其当时一个景物的背景图时,感觉像由远及近,效果还是很不错的。

    具体实现也不复杂,上代码:

布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/iv"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/img"
        />
</LinearLayout>

Activity:

public class SplashActivity extends Activity {

    Context ctx;
    ImageView iv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_layout);
        ctx=SplashActivity.this;
        iv= (ImageView) findViewById(R.id.iv);




        ObjectAnimator oax=ObjectAnimator.ofFloat(iv,"scaleX",1f,1.2F);
        ObjectAnimator oay=ObjectAnimator.ofFloat(iv,"scaleY", 1f,1.2F);
        AnimatorSet set=new AnimatorSet();
        set.setDuration(2000).play(oax).with(oay);
        set.start();

        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
               Toast.makeText(ctx,"end",Toast.LENGTH_SHORT).show();
            }
        });




    }


}

 

posted @ 2016-03-29 11:09  一首简单的歌  阅读(316)  评论(0编辑  收藏  举报