Android Splash Screen动画(从左到右)

时间:2016-05-01 13:25:54

标签: android android-animation splash-screen

目前,我正在尝试使用此动画创建启动画面: Progress Bar Effect

从一开始,我就想创建进度条,但是,我无法做到,也无法找到确切的设计。因此,我计划使用动画方法,但大部分教程都淡入/我们或从左到右移动项目。知道如何在启动画面中创建这种动画(3秒)吗?

2 个答案:

答案 0 :(得分:1)

您可以使用处理程序手动进行此操作,以便在一段时间后显示图像。

首先,您将创建一个包含这些图像的布局并使其不可见,然后在处理程序中逐个显示它们。

这是怎么做的。

这是布局:

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/img1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:src="@android:drawable/presence_online"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/img2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:src="@android:drawable/presence_online"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/img3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:src="@android:drawable/presence_online"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/img4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:src="@android:drawable/presence_online"
        android:visibility="invisible" />

</LinearLayout>

,这在java类中:

final int TIME_OUT = 1000;

        final ImageView imageView1 = (ImageView) findViewById(R.id.img1);
        final ImageView imageView2 = (ImageView) findViewById(R.id.img2);
        final ImageView imageView3 = (ImageView) findViewById(R.id.img3);
        final ImageView imageView4 = (ImageView) findViewById(R.id.img4);

        new Handler().postDelayed(new Runnable() {
            // This method will be executed once the timer is over
            @Override
            public void run() {
                imageView1.setVisibility(View.VISIBLE);
            }
        }, TIME_OUT);

        new Handler().postDelayed(new Runnable() {
            // This method will be executed once the timer is over
            @Override
            public void run() {
                imageView2.setVisibility(View.VISIBLE);
            }
        }, TIME_OUT * 2);

        new Handler().postDelayed(new Runnable() {
            // This method will be executed once the timer is over
            @Override
            public void run() {
                imageView3.setVisibility(View.VISIBLE);
            }
        }, TIME_OUT * 3);
        new Handler().postDelayed(new Runnable() {
            // This method will be executed once the timer is over
            @Override
            public void run() {
                imageView4.setVisibility(View.VISIBLE);
            }
        }, TIME_OUT * 4);

你可以改变TIME_OUT,因为它适合你,所以android:src。

我试过这个并且效果很好。

如果有任何不清楚的地方,请告诉我。

答案 1 :(得分:0)

要将ProgressBar效果作为进度指标,请查看参考here。另请查看建议线程以及所选答案here - 它们显示了如何进行进度条动画。您还可以查看选定的答案here,了解如何使进度条顺利更新。我希望这能指出你正确的方向。