android:GraphView背景绘制不正确

android:GraphView背景绘制不正确,android,android-layout,android-graphview,Android,Android Layout,Android Graphview,我正在尝试用graphview库实现一个后台。除了没有正确绘制图形背景外,其他一切都正常工作。我对库做了一些修改,但未修改的库也给了我同样的问题。请帮忙 谢谢,萨希尔 我的代码: @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View inflatedV

我正在尝试用graphview库实现一个后台。除了没有正确绘制图形背景外,其他一切都正常工作。我对库做了一些修改,但未修改的库也给了我同样的问题。请帮忙

谢谢,萨希尔

我的代码:

@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;
}
@覆盖
创建视图上的公共视图(最终布局扁平充气机、最终视图组容器、最终捆绑保存状态){
最终视图充气视图=充气机。充气(R.layout.fragment_图,容器,假);
this.graphView=newlinegraphview(this.getActivity().getApplicationContext(),“”){
@凌驾
受保护的字符串formatLabel(最终双精度值,最终布尔值isValueX){
if(isValueX){
最终SimpleDataFormat日期格式=新SimpleDataFormat(“HH:mm”);
return dateFormat.format(新日期((长)值*1000));
}否则{
return super.formatLabel(value,isValueX);//让y值为普通格式
}
}
};
这个.graphView.setVerticalLabels(新字符串[]{“100”、“90”、“80”、“70”、“60”、“50”、“40”、“30”、“20”、“10”、“0”});
此.graphView.setScrollable(true);
此.graphView.setScalable(true);
此.graphView.setDruckGround(真);
这个.graphView.setBackgroundColor(Color.rgb(194223255));
此.graphView.setManualYAxis(真);
此.graphView.setManualYAxisBounds(100.0,0.0);
this.graphView.setEnabled(false);
this.updateGraph();
最终线性布局=(线性布局)充气视图。findViewById(R.id.layout\u graph\u view);
layout.addView(this.graphView);
返回充气视图;
}
私有void updateGraph(){
//删除了大量代码以获取图形数据
最终长currentTime=System.currentTimeMillis()/1000L;
如果(本系列集){
//TODO:this.graphView.removeSeries(0);
}
this.graphView.addSeries(dataSet.first);
如果((dataSet.second+86400L)
开发人员已修复此问题