android:GraphView背景无法正确绘制

时间:2013-11-12 12:29:40

标签: android android-layout android-graphview

我试图用graphview库实现背景。除非未正确绘制图形背景,否则一切正常。我已经修改了一点库但未经修改的库也给了我同样的问题。请帮忙

谢谢,Sahil

improper graph

我的代码:

@Override
      public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
    final View inflatedView = inflater.inflate(R.layout.fragment_graph, container, false);

    this.graphView = new LineGraphView(this.getActivity().getApplicationContext(), "") {

        @Override
        protected String formatLabel(final double value, final boolean isValueX) {
            if (isValueX) {
                final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
                return dateFormat.format(new Date((long) value * 1000));
            } else {
                return super.formatLabel(value, isValueX); // let the y-value be normal-formatted
            }
        }
    };
    this.graphView.setVerticalLabels(new String[]{"100", "90", "80", "70", "60", "50", "40", "30", "20", "10", "0"});
    this.graphView.setScrollable(true);
    this.graphView.setScalable(true);
    this.graphView.setDrawBackground(true);
    this.graphView.setBackgroundColor(Color.rgb(194, 223, 255));
    this.graphView.setManualYAxis(true);
    this.graphView.setManualYAxisBounds(100.0, 0.0);
    this.graphView.setEnabled(false);
    this.updateGraph();
    final LinearLayout layout = (LinearLayout) inflatedView.findViewById(R.id.layout_graph_view);
    layout.addView(this.graphView);

    return inflatedView;
}

private void updateGraph() {
 // Removed a lot of code to get the graph data
    final Long currentTime = System.currentTimeMillis() / 1000L;
    if (this.seriesSet) {
        //TODO: this.graphView.removeSeries( 0 );
    }
    this.graphView.addSeries(dataSet.first);
    if ((dataSet.second + 86400L) < currentTime) {
        this.graphView.setViewPort((currentTime - 43200), 43200);
    }
    this.seriesSet = true;
}

1 个答案:

答案 0 :(得分:1)

开发人员已解决此问题。 Referenced commit