【发布时间】:2017-02-28 03:30:07
【问题描述】:
当用户单击捕获按钮时,我想制作像 fadeIn-fadeOut 这样的动画。 当我在 animatedView 和 android:fromAlpha="1.0", android:toAlpha="0.0" 上设置 alpha 1.0 时,它可以工作,但我需要反转它。 这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<SurfaceView
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<View
android:id="@+id/animated_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:alpha="0.0"/>
<Button
android:id="@+id/button_capture"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
这是我的动画 xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:duration="500"
android:fromAlpha="0.0"
android:repeatCount="1"
android:repeatMode="reverse"
android:toAlpha="1.0"
/>
</set>
这就是我运行它的方式:
animClick = AnimationUtils.loadAnimation(getApplicationContext(),
R.anim.click);
@OnClick(R.id.button_capture)
void onCaptureClick() {
camera.takePicture(null, null, jpegCallback);
animatedView.startAnimation(animClick);
}
什么也没发生,我做错了什么?
【问题讨论】:
标签: android animation view surfaceview