K
K
kirawa2014-09-10 12:08:11
Android
kirawa, 2014-09-10 12:08:11

How to create such an animation?

private void setWeigtnMemory(float k,int visibility){
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
        ViewGroup.LayoutParams.MATCH_PARENT, 0);
        float v = context.getResources().getDisplayMetrics().density;
        params.weight = k;
        params.topMargin = (int) (20*v);
        params.leftMargin = (int) (10*v);
        params.rightMargin = (int) (10*v);
        relativeMemory.setVisibility(visibility);
        relativeWeigth.setLayoutParams(params);
    }

I call the method like this: or Everything is fine, but advise how to attach an animation to this case so that it works smoothly
setWeigtnMemory(1.2f,View.GONE);
setWeigtnMemory(2.4f,View.VISIBLE);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Falseclock, 2014-09-18
@Falseclock

If this is a picture, then through PorterDuff.Mode
If it is a container, then through setAlpha
The algorithm is simple, for example, reduce/increase transparency by 25% 4 times. Or 5 times 20%. Or 10 times 10%.
If the picture is in a container, and you need to show a smooth disappearance, then first change the transparency of the picture from 100 to 0, and at the end assign the container View.GONE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question