【发布时间】:2013-07-02 14:43:15
【问题描述】:
我正在尝试为我的“自定义”媒体控制器制作一个简单的淡出动画。
我遇到的问题是布局不会淡出,它会在一秒钟后消失(好像我会延迟 1 秒将可见性设置为 GONE)。
这是我的功能:
private void fadeOut(final View view) {
final AlphaAnimation fadeOutAnimation = new AlphaAnimation(1.0F, 0.0F);
fadeOutAnimation.setDuration(1000);
fadeOutAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.setVisibility(View.GONE);
}
});
view.startAnimation(fadeOutAnimation);
}
以及我试图隐藏的布局:
<RelativeLayout
android:id="@+id/videoControllerContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:alpha="50"
android:background="@color/DarkGrey" >
<ImageButton
android:id="@+id/playVideoButton"
android:layout_width="wrap_content"
android:layout_height="50dip"
android:layout_alignParentLeft="true"
android:background="@null"
android:contentDescription="@string/playButton"
android:scaleType="fitCenter"
android:src="@drawable/play" />
<ImageButton
android:id="@+id/fullScreenVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:background="@null"
android:contentDescription="@string/fullscreen"
android:src="@drawable/fullscreen" />
</RelativeLayout>
值得一提的是,所有这些都在片段中使用。
我希望有更多经验的人会花时间告诉我我做错了什么。
【问题讨论】:
标签: java android animation fade alpha