GradientRadioLayout.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:CompoundLayout 作者:
/**
 * Update gradient parameters.
 */
private void updateGradientParameters() {
    // - Initialize gradient.
    mSideHypot = (int) Math.hypot(getWidth(), getHeight());
    ShapeDrawable mDrawable = new ShapeDrawable(new RectShape());
    final double radiansAngle = Math.toRadians(mDegreesAngle);
    mDrawable.getPaint().setShader(new LinearGradient(0, 0, (int) (mSideHypot * Math.cos(radiansAngle)), (int) (mSideHypot * Math.sin(radiansAngle)), mColorA, mColorB, Shader.TileMode.REPEAT));

    // - Initialize foreground gradient layout.
    if (mForegroundLayout == null) {
        mForegroundLayout = new FrameLayout(getContext());
        mForegroundLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        addView(mForegroundLayout);
    }
    mForegroundLayout.setVisibility(isChecked() ? View.VISIBLE : View.INVISIBLE);
    mForegroundLayout.setForeground(mDrawable);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号