AndroidPlot получить Y-положение линии - PullRequest
0 голосов
/ 11 мая 2018

Я бы хотел разместить TextLabelWidget над определенной линией на графике Android.

Есть ли способ подключить его напрямую к линии или рассчитать точное положение Y линии.

Получить правильную позицию точки в AndroidPlot

https://stackoverflow.com/posts/comments/87452134?noredirect=1

Пока это мой Код:

TextLabelWidget txtText = new TextLabelWidget(
                    rdPuls.getLayoutManager(),
                    "Some Text",
                    null,  // TextLabelWidget instances "pack" to wrap the actual text size
                    TextOrientation.HORIZONTAL);
            txtText.getLabelPaint().setColor(getColor(R.color.biosign_green));
            txtText.getLabelPaint().setTextSize(PixelUtils.dpToPix(15));
            txtText.position(
                    // add a right margin of 4dp:
                    0, PixelUtils.dpToPix(80)

                    // center the text with the plot space vertically:
                    PixelUtils.dpToPix(80), VerticalPositioning.ABSOLUTE_FROM_BOTTOM,

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

Фото:

enter image description here

1 Ответ

0 голосов
/ 11 мая 2018

Если вы просто хотите показать прямую линию с некоторым текстом, вы можете использовать один из подклассов XYValueMarker:

YValueMarker marker = new YValueMarker(35, "someText");
plot.addMarker(marker);

// later, if you want to dynamically move it around: (dont forget 
// to call plot.redraw() if you do though)
marker.setValue(34);

Вы можете использовать альтернативные конструкторы или marker.setTextPosition(...) для точного управлениягде появляется текст.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...