我正在使用androidplot-core-0.6.1.jar,我正在修改quickstart教程中的SimpleXYPlotActivity示例。我已经删除了一些项目和边距/填充,但我想要做的并且无法找到方法如何删除图表左侧的空间。我在下面的图片中用红色标记了我要删除的空间。可以这样做吗?
Red shows what I want to remove
活动代码:
public class MyXYPlotActivity extends Activity {
private XYPlot plot;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.simple_xy_plot_example);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);
Number[] series1Numbers = {1, 8, 5, 2, 7, 4};
XYSeries series1 = new SimpleXYSeries(
Arrays.asList(series1Numbers), // SimpleXYSeries takes a List so turn our array into a List
SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
"Foo"); // Set the display title of the series
LineAndPointFormatter series1Format = new LineAndPointFormatter();
series1Format.setPointLabelFormatter(new PointLabelFormatter());
series1Format.configure(getApplicationContext(),
R.xml.line_point_formatter_with_plf1);
plot.addSeries(series1, series1Format);
plot.setDomainValueFormat(new DecimalFormat("#"));
plot.setRangeValueFormat(new DecimalFormat("#"));
plot.setTitle("Title");
plot.setRangeBoundaries(0,10, BoundaryMode.FIXED);
int length = 30;
plot.setDomainBoundaries(1,length, BoundaryMode.FIXED);
plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1);
plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 1);
plot.setMarkupEnabled(true);
plot.setTicksPerRangeLabel(1);
plot.setTicksPerDomainLabel(1);
plot.getGraphWidget().setDomainLabelOrientation(90);
plot.getLayoutManager().remove(plot.getLegendWidget());
plot.getLayoutManager().remove(plot.getRangeLabelWidget());
plot.getLayoutManager().remove(plot.getDomainLabelWidget());
plot.setPlotMargins(0, 0, 0, 0);
plot.setPlotPadding(0, 0, 0, 0);
plot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
plot.getRangeLabelWidget().setHeight(0);
plot.getRangeLabelWidget().setWidth(0);
plot.getRangeLabelWidget().setPadding(0, 0, 0, 0);
plot.getRangeLabelWidget().setMargins(0, 0, 0, 0);
plot.getDomainLabelWidget().setHeight(0);
plot.getDomainLabelWidget().setWidth(0);
plot.getDomainLabelWidget().setPadding(0, 0, 0, 0);
plot.getDomainLabelWidget().setMargins(0, 0, 0, 0);
}
}
编辑:我找到了解决方案:
XYGraphWidget g = plot.getGraphWidget();
g.setRangeLabelWidth(25);
g.setDomainLabelWidth(25);
以上内容有效。
答案 0 :(得分:0)
看起来你想减少/删除graphWidget的边距和/或填充。尝试将这些添加到您的代码中以查看它是否具有所需的效果......您显然需要使用适合您的应用程序的非零值:
plot.getGraphWidget().setMarginLeft(0);
plot.getGraphWidget().setPaddingLeft(0);
另请查看以下类似问题: