I'm trying to do a simple fade-out animation for my "custom" media controller.
The problem I'm having is that the layout does not fade-out, it just disappears after a second (as if I would set the Visibility to GONE with a 1 second delay).
This is my function:
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);
}
And the layout that I'm trying to hide:
<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>
It's worth mentioning that all this is being used inside a fragment.
I'm hoping that someone with a bit more experience will take the time and let me know what I'm doing wrong.