我有一个前景图像,中间有一个透明的空间,这样你就可以通过它看到背景颜色,从白色开始。我需要创建一个擦除效果,其中颜色变化从白色到蓝色,从左到右在屏幕上移动。不仅仅是从一个消失到另一个。它需要像一个蓝色的窗帘被拉过屏幕,慢慢改变颜色出现在中间的图像。
目前,我已将其设置为使用ValueAnimator的基本淡出效果,但所需的是这种擦除效果。我怎样才能创造这个窗帘擦拭的效果?
为了澄清我正在寻找的效果是一个坚实的彩色窗帘被慢慢拉过一个白色的屏幕,所以在最后,所有的是蓝色。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:foreground="@drawable/loading_page_4"
android:id="@+id/splash_color_layout" >
</FrameLayout>发布于 2016-01-08 19:44:15
有几种方法可以解决这个问题,但最简单和最简单的方法是在框架中添加一个子视图。
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:foreground="@drawable/loading_page_4"
android:id="@+id/splash_color_layout" >
<View
android:id="@+id/wipe_animation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue"
android:visibility="invisible" />
</FrameLayout>然后,当您想要启动动画时(必须在视图放置之后完成):
wipeAnimationView.setVisibility(View.VISIBLE);
wipeAnimationView.setTranslationX(-wipeAnimationView.getWidth());
wipeAnimationView.animate().translationX(0.0f).start();重要的是要注意的是,如果您是启动动画之前,屏幕布局,视图的宽度将是0,它将没有任何影响。你应该view.post(() -> runAnimation());
https://stackoverflow.com/questions/34682305
复制相似问题