gpt4 book ai didi

android - 如何更改图例小部件在 androidplot 中的位置

转载 作者:行者123 更新时间:2023-11-30 03:11:34 25 4
gpt4 key购买 nike

我正在努力将 androidplot 中的图例小部件移动到我想要的地方。

我正在尝试使用 androidplot 来呈现一组数据。我遵循通过调用 DemoApp 中使用的 position() 方法将图例小部件放置到一个点的方法。但我从来没有成功过。我被这个封锁了将近 1 周。有人可以帮我检查一下我的代码是否有错误。除了示例代码,我没有找到任何关于如何使用这个库的文档。

我的布局 xml:

<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_below="@+id/seperator1"
androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.legendWidget.heightMetric.value="25dp"
androidPlot.graphWidget.marginBottom="25dp"
androidPlot.graphWidget.marginLeft="15dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.marginTop="20dp"
androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
androidPlot.legendWidget.positionMetrics.anchor="left_top"
androidPlot.legendWidget.positionMetrics.xPositionMetric.value="0"
androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
androidPlot.legendWidget.widthMetric.value="100dp"
androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size" />
<!-- androidPlot.graphWidget.gridLinePaint.color="#000000"/> -->

我的源代码:

 private void makePlotPretty() {
// use a 2x2 grid with room for 4 items:
plot.getLegendWidget().setTableModel(new DynamicTableModel(2, 2));

// add a semi-transparent black background to the legend
// so it's easier to see overlaid on top of our plot:
Paint bgPaint = new Paint();
bgPaint.setColor(Color.BLACK);
bgPaint.setStyle(Paint.Style.FILL);
bgPaint.setAlpha(255);

plot.getLegendWidget().setBackgroundPaint(bgPaint);

/* plot.getLegendWidget().setPositionMetrics(null);
*/

plot.getLegendWidget().setWidth(PixelUtils.dpToPix(40), SizeLayoutType.FILL);

plot.getGraphWidget().setRangeLabelHorizontalOffset(-1);

plot.getLegendWidget().position(125, XLayoutStyle.ABSOLUTE_FROM_LEFT, 100, YLayoutStyle.ABSOLUTE_FROM_TOP, AnchorPosition.LEFT_TOP);

}

最佳答案

documentation包括 page for the legend带有示例代码,包括定位图例。

临界线看起来是

       mySimpleXYPlot.position(
mySimpleXYPlot.getLegendWidget(),
20,
XLayoutStyle.ABSOLUTE_FROM_RIGHT,
35,
YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
AnchorPosition.RIGHT_BOTTOM);

关于android - 如何更改图例小部件在 androidplot 中的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20859451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com