尝试从GraphView生成图像时出现非法状态异常

时间:2018-02-02 17:18:51

标签: android bitmap hardware-acceleration android-graphview

我正在尝试从GrapView生成图像,但是我得到了以下错误,尽管我已将hardwareAccelerated设置为true:

java.lang.IllegalStateException: GraphView must be used in hardware accelerated mode.You can use android:hardwareAccelerated="true" on your activity. Read this for more info:https://developer.android.com/guide/topics/graphics/hardware-accel.html

以下是我收到错误的代码:

graphView.addSeries(RepresentationHelper.getHashMapnewAPI().get(object.getName()));
            graphView.setTitle("");

            //setting y label for bounds with the min and max value obtained from the request
            graphView.getViewport().setYAxisBoundsManual(true);
            double low = graphView.getSeries().get(0).getLowestValueY();
            double high = graphView.getSeries().get(0).getHighestValueY();
            graphView.getViewport().setMinY(low);
            graphView.getViewport().setMaxY(high);

            graphView.getGridLabelRenderer().setHorizontalLabelsVisible(false);
            graphView.getGridLabelRenderer().setVerticalLabelsVisible(false);
            graphView.getGridLabelRenderer().setHighlightZeroLines(false);
            graphView.getGridLabelRenderer().setGridColor(Color.WHITE);

            Bitmap bitmap;
            graphView.setDrawingCacheEnabled(true);
            bitmap = Bitmap.createBitmap(graphView.getDrawingCache());
            graphView.setDrawingCacheEnabled(false);

            ImageView imageView = (ImageView) convertView.findViewById(R.id.imageView);
            //imageView.setImageDrawable(context.getResources().getDrawable(R.drawable.grafico_definitivo));
            imageView.setImageBitmap(bitmap);

1 个答案:

答案 0 :(得分:1)

你应该尝试这样的事情:

df.set_index(['user', 'report']).groupIDs.apply(pd.Series).stack().reset_index(['user', 'report'], name='groupIDs')

现在,你在graphmap的图像上有位图!!

希望这可以帮到你!! :)