Android 启动画面动画(从左到右)
Android Splash Screen Animation (Left to Right)
目前,我正在尝试使用此动画创建闪屏:
Progress Bar Effect
一开始我想做进度条,但是做不到,也找不到具体的设计。因此,我打算使用动画方法,但大部分教程都是淡入淡出 in/our 或从左向右移动项目。知道如何在初始屏幕(3 秒)中创建这种动画吗?
ProgressBar作为进度指示器的效果,请参考here. Also take a look at thread of suggestions as well as the selected answer here - they show how to do a progress bar animation. You can also look at the selected answer here让进度条平滑更新的参考资料。我希望这能为您指明正确的方向。
您可以使用处理程序手动执行此操作,使图像在一段时间后显示。
首先您将创建一个包含这些图像的布局并使它们不可见,然后在处理程序中一个一个地显示它们。
这是操作方法。
这是在布局中:
<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 class:
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。
我试过了,效果很好。
如果有任何不清楚的地方,请告诉我。
目前,我正在尝试使用此动画创建闪屏: Progress Bar Effect
一开始我想做进度条,但是做不到,也找不到具体的设计。因此,我打算使用动画方法,但大部分教程都是淡入淡出 in/our 或从左向右移动项目。知道如何在初始屏幕(3 秒)中创建这种动画吗?
ProgressBar作为进度指示器的效果,请参考here. Also take a look at thread of suggestions as well as the selected answer here - they show how to do a progress bar animation. You can also look at the selected answer here让进度条平滑更新的参考资料。我希望这能为您指明正确的方向。
您可以使用处理程序手动执行此操作,使图像在一段时间后显示。
首先您将创建一个包含这些图像的布局并使它们不可见,然后在处理程序中一个一个地显示它们。
这是操作方法。
这是在布局中:
<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 class:
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。
我试过了,效果很好。
如果有任何不清楚的地方,请告诉我。