SeekBarWidget.java 文件源码

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

项目:android_ui 作者:
/**
 * Specifies a transformation for the discrete components. Depends on the implementation,
 * this can change alpha value of some discrete components or theirs current scale for example.
 * <p>
 * This method can be used to animate revealing/concealing of the discrete components or theirs
 * immediate hiding/showing.
 *
 * @param transformation The desired transformation from the range {@code [0.0, 1.0]}.
 *                       Transformation {@code 0.0} means that discrete components will be
 *                       hided, {@code 1.0} means that they will be visible.
 */
@Keep
void setDiscreteTransformation(float transformation) {
    if (this.transformation != transformation) {
        this.transformation = transformation;
        // Scale up/down the discrete indicator and the thumb in a way when one is fully scaled
        // up the other is fully scaled down and reversed.
        setThumbScale(1 - transformation);
        setDiscreteIndicatorScale(transformation);

        // Fade in/out the text of discrete indicator during the indicator is at least 75% transformed/visible.
        if (transformation > 0.75) {
            final int alpha = Math.round((transformation - 0.75f) / 0.25f * 255);
            setDiscreteIndicatorTextAlpha(alpha);
        } else {
            setDiscreteIndicatorTextAlpha(0);
        }

        // Fade in/out discrete interval.
        setDiscreteIntervalAlpha(Math.round(transformation * 255));
        invalidate();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号