我的xml是
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/graph_view" />
和代码
graphView = (GraphView) findViewById(R.id.graph_view);
LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[]
{
new DataPoint(0, 1),
new DataPoint(2, 3),
new DataPoint(4, 6),
new DataPoint(6, 9),
new DataPoint(8, 9),
new DataPoint(10, 9),
new DataPoint(12, 1) ,
new DataPoint(14, 9),
});
graphView.addSeries(series);
StaticLabelsFormatter staticLabelsFormatter = new StaticLabelsFormatter(graphView);
staticLabelsFormatter.setHorizontalLabels(new String[] {"0", "2", "4","6", "8", "10","12", "14", "16","18", "20", "22","24"});
staticLabelsFormatter.setVerticalLabels(new String[] {"0", "2", "4","6","8","10","12"});
graphView.getGridLabelRenderer().setLabelFormatter(staticLabelsFormatter);
graphView.getViewport().setScrollable(true);
graphView.getViewport().isScrollable();
graphView.getViewport().scrollToEnd();
我想知道我是如何设置水平滚动的,因为x轴水平彼此非常接近而且ui非常糟糕。任何人都可以帮助找到解决方案......
答案 0 :(得分:0)
//激活水平缩放和滚动
graphView.getViewport().setScalable(true);
//激活水平滚动
graphView.getViewport().setScrollable(true);
//激活水平和垂直缩放和滚动
graphView.getViewport().setScalableY(true);
//激活垂直滚动
graphView.getViewport().setScrollableY(true);