DatePickerView.java 文件源码

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

项目:androidtools 作者:
private void drawData(Canvas canvas) {
    // Draw the selected text first, and then draw up the rest of the text.
    float scale = parabola(mViewHeight / 4.0f, mMoveLen);
    float size = (mMaxTextSize - mMinTextSize) * scale + mMinTextSize;
    mPaint.setTextSize(size);
    mPaint.setAlpha((int) ((mMaxTextAlpha - mMinTextAlpha) * scale + mMinTextAlpha));
    // Text center drawing, pay attention to the calculation of baseline to reach the center, y value is text central coordinates.
    float x = (float) (mViewWidth / 2.0);
    float y = (float) (mViewHeight / 2.0 + mMoveLen);
    FontMetricsInt fmi = mPaint.getFontMetricsInt();
    float baseline = (float) (y - (fmi.bottom / 2.0 + fmi.top / 2.0));

    canvas.drawText(mDataList.get(mCurrentSelected), x, baseline, mPaint);
    // Draw the top data.
    for (int i = 1; (mCurrentSelected - i) >= 0; i++) {
        drawOtherText(canvas, i, -1);
    }
    // Draw below data.
    for (int i = 1; (mCurrentSelected + i) < mDataList.size(); i++) {
        drawOtherText(canvas, i, 1);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号