纵向的时间轴图表

public class CharterYLabels extends CharterLabelsBase {  public CharterYLabels(Context context) {    this(context, null);  }  public CharterYLabels(Context context, AttributeSet attrs) {    this(context, attrs, 0);  }  public CharterYLabels(Context context, AttributeSet attrs, int defStyleAttr) {    super(context, attrs, defStyleAttr);  }  @TargetApi(Build.VERSION_CODES.LOLLIPOP)  public CharterYLabels(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {    super(context, attrs, defStyleAttr, defStyleRes);  }  @Override  public void draw(Canvas canvas) {    super.draw(canvas);if (values == null || values.length == 0) {  return;}final int valuesLength = values.length;final float height = getMeasuredHeight();final float width = getMeasuredWidth();final float gap = height / (valuesLength - 1);int visibilityPatternPos = -1;for (int i = 0; i < valuesLength; i++) {  if (visibilityPatternPos + 1 >= visibilityPattern.length) {    visibilityPatternPos = 0;  } else {    visibilityPatternPos++;  }  if (visibilityPattern[visibilityPatternPos]) {    Rect textBounds = new Rect();    paintLabel.getTextBounds(values[i], 0, values[i].length(), textBounds);    int textHeight = 2 * textBounds.bottom - textBounds.top;    float textWidth = textBounds.right;    float x;    float y;    switch (horizontalGravity) {      default:        // HORIZONTAL_GRAVITY_LEFT        x = 0;        break;      case HORIZONTAL_GRAVITY_CENTER:        x = (width - textWidth) / 2;        break;      case HORIZONTAL_GRAVITY_RIGHT:        x = width - textWidth;        break;    }    if (i == 0) {      y = height;    } else if (i == valuesLength - 1) {      y = textHeight;    } else {      y = gap * i + (textHeight / 2);    }    canvas.drawText(values[i], x, y-5, paintLabel);  }}

}
}

更多相关文章

  1. Android自定义view七时间轴(二)---横向的图表时间轴
  2. android饼状图表
  3. 【Android】 横向纵向滚轮控件
  4. android仿微信朋友网、悬浮窗、时间轴、图表、刻度尺、RecyclerV
  5. 手撸一个Android饼状图表
  6. 简单的 Android 系统主要版本对比图表
  7. android 图表引擎AChartEngine(线性图)
  8. Android之关于图表
  9. Android 图表

随机推荐

  1. 7.ProgressBar
  2. Android 禁止Edittext弹出系统软键盘 的
  3. Android中的Button自定义点击效果实例代
  4. 移动开发书籍推荐
  5. android软键盘事件处理
  6. android中BroadCastReceiver使用(广播的
  7. 详解Android中的屏幕方向
  8. Android(安卓)唯一识别码
  9. MVVM在Android中的初学之路
  10. Windows环境下Android(安卓)Studio v1.0