Search code examples
androidrippledrawable

Where calculating RippleDrawable radius wtih RADIUS_AUTO


Docs says Radius value that specifies the ripple radius should be computed based on the size of the ripple's container. but i can't find exactly where it calculating. I tried to fugire it out with debugger but unsuccesful.

Can you tell me where this calculation take place?


Solution

  • I found it. That calculation perform in setup(float, int) method of RippleComponent class:

    public final void setup(float maxRadius, int densityDpi) {
        if (maxRadius >= 0) {
            mHasMaxRadius = true;
            mTargetRadius = maxRadius;
        } else {
            mTargetRadius = getTargetRadius(mBounds); // this place!
        }
    
        mDensityScale = densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
    
        onTargetRadiusChanged(mTargetRadius);
    }
    

    Exactly this class handles size and positioning common to the ripple & focus states. Neither RippleState nor RippleDrawable.