Android 自帶的常用註解

1、在註釋中實現鏈接跳轉
    /**
     * ... ...
     * @see #invalidate()
     * @see #postInvalidateDelayed(long)
     */
    public void postInvalidate() {
        postInvalidateDelayed(0);
    }

    /**
     * ... ...
     * @see View#setX(float)
     */
    public ViewPropertyAnimator x(float value) {
        animateProperty(X, value);
        return this;
    }

    /**
     * ... ...
     * @see Animator.AnimatorListener
     */
    public ViewPropertyAnimator setListener(Animator.AnimatorListener listener) {
        mListener = listener;
        return this;
    }

    /**
     * ... ...
     * @see android.animation.ValueAnimator.AnimatorUpdateListener
     */
    public ViewPropertyAnimator setUpdateListener(ValueAnimator.AnimatorUpdateListener listener) {
        mUpdateListener = listener;
        return this;
    }

    /**
     * ... ...
     * @see View#setLayerType(int, android.graphics.Paint)
     */
    public ViewPropertyAnimator withLayer() {
         ... ...
    }
2、限定參數類型
TextView.setTextColor(@ColorInt int color)
3、限定參數類型及範圍
TimePicker.setHour(@IntRange(from = 0, to = 23) int hour)
public static class ByteArray {
	private @IntRange(from = 0) int mSize;
}
public class TextView ...{
    @FloatRange(from = 0.0, to = 1.0)
    private float getHorizontalFadingEdgeStrength(float position1, float position2) {
        final int horizontalFadingEdgeLength = getHorizontalFadingEdgeLength();
        if (horizontalFadingEdgeLength == 0) return 0.0f;
        final float diff = Math.abs(position1 - position2);
        if (diff > horizontalFadingEdgeLength) return 1.0f;
        return diff / horizontalFadingEdgeLength;
    }
}

參考文章:
1、https://www.android-doc.com/reference/packages.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章