我正在尝试使用GraphView,但似乎没有标签:/

这是我的GraphView:

// init example series data
GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {
    new GraphViewData(1, 2.0d)
    , new GraphViewData(2, 1.5d)
    , new GraphViewData(3, 2.5d)
    , new GraphViewData(4, 1.0d)
});
 
GraphView graphView = new LineGraphView(this , "GraphViewDemo");
graphView.setHorizontalLabels(new String[] {"2 days ago", "yesterday", "today", "tomorrow"});
graphView.setVerticalLabels(new String[] {"high", "middle", "low"});
graphView.addSeries(exampleSeries);
 
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
layout.addView(graphView);


这是我的xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" android:id="@+id/layout"
    android:orientation="vertical">
</LinearLayout>


这是我得到的:

大编辑!

现在出现了标签,但它们太大了,如何减少字体字母和整体显示?

最佳答案

问题可能出在您的文本为白色。试一试

graphView.getGraphViewStyle()。setHorizo​​ntalLabelsColor(Color.BLACK);
graphView.getGraphViewStyle()。setVerticalLabelsColor(Color.BLACK);

文字大小可以如下更改...
graphView.getGraphViewStyle()。setTextSize(11);

关于java - Android GraphView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24299918/

10-11 22:51