How to make android browse to redraw its background? / Maybe the animation blocks its operation

Is there any way to get android view to redraw its background? I set a flexible shape with a gradient as the background, which works great, but after changing the height of the view, you can see these ugly gradient steps.

What can I do? I tried view.invalidate()and view.refreshDrawableState()without visible differences.

Thank!

// EDIT: Here are a few more details and my code: After your answers, I think the bandages are the result of my probably bad code. That's what I'm doing:

Here is my code:

public void onAnimationEnd(Animation animation)
{
    MyView view = (MyView) ((ExtendedScaleAnimation) animation).getView();
    view.getLayoutParams().width = toWidth;
    view.getLayoutParams().height = toHeight;
    view.clearAnimation();
    view.requestLayout();
    view.refreshBackground(); // background will be changed
}

On the device, you can see that the background image can be changed, but there is a flicker that seems to me like changing the background before the animation ends. Programmatically, it must be finished! Or am I wrong?

Thanks again!

+3
source share
1 answer

: v.setBackgroundResource(); v.setBackgroundResource(... my drawable...);

+2

Source: https://habr.com/ru/post/1786687/


All Articles