I have simple task: fade screen (+ other actions, but it doesnt matter now) when something happens (say, button pressed).
My minSDKVersion is 11. I do it in this way: activity layout contains a view:
<View
android:id="@+id/bgFadingView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:background="@android:color/black" />
and method where I fade screen is as follows:
protected void fadeBGView(boolean fadeIn)
{
ObjectAnimator animator = ObjectAnimator.ofFloat(bgFadingView, "alpha", fadeIn ? 0.75f : 0f); //bgFadingView is initialized via findViewById(R.id.bgFadingView);
animator.setDuration(1000);
animator.start();
}
in other words, I have black view, which occupies the whole screen and when I need to fadeIn, I change view’s alpha from 0 to 0.75.
The problem is that it works with bad framerate… I see fading animation frame by frame – it works at about 15fps. What am I doing wrong? Android system fading works much more smoothly – I want to archieve the same result or close. How to?
All I had to do was:
default frame delay was too long, so my animations didnt work smoothly. The problem was not due to device performance limitations.