添加第二个Y轴标题,标记行+添加行标题

时间:2018-05-03 14:37:46

标签: android androidplot

我遇到了以下问题,

我想:

  • 在右侧的Android Plot中添加第二个Axis Caption
  • 同样的标签,如右(。也许)
  • 用颜色和一些文字标记一行
  • 紫色线应始终位于黄色前面

有没有办法做到这一点?

因为一张图片说的数千字以上。

enter image description here

1 个答案:

答案 0 :(得分:1)

没有内置的第二轴标题,但由于它们只是TextLabelWidget的实例,因此很容易添加自己的标题。这是一个为SimpleXYPlotActivity示例

添加标签的示例
    TextLabelWidget textLabelWidget = new TextLabelWidget(
            plot.getLayoutManager(),
            "some text",
            null,  // TextLabelWidget instances "pack" to wrap the actual text size
            TextOrientation.VERTICAL_ASCENDING);

    textLabelWidget.getLabelPaint().setColor(Color.RED);
    textLabelWidget.getLabelPaint().setTextSize(PixelUtils.dpToPix(24));

    plot.getLayoutManager().add(textLabelWidget);
    textLabelWidget.position(
            // add a right margin of 4dp:
            PixelUtils.dpToPix(4), HorizontalPositioning.ABSOLUTE_FROM_RIGHT,

            // center the text with the plot space vertically:
            0, VerticalPositioning.ABSOLUTE_FROM_CENTER,

            // use the middle of the right edge of the text widget as the anchor:
            Anchor.RIGHT_MIDDLE);

产生:

enter image description here

相关问题