如何在android中将谷歌图表转换为图像?

如何在android中将谷歌图表转换为图像?,android,charts,bitmap,Android,Charts,Bitmap,我想将我用google charts api制作的折线图转换为图像。我该怎么做?我在网上找不到任何有帮助的东西。尝试将您的google图表转换为位图,并将其设置为图像到imageview 例如: Bitmap bitmap = loadChart("your google image url"); 负荷图法 private Bitmap loadChart(String urlRqs) { Bitmap bm = null; InputStream inputS

我想将我用google charts api制作的折线图转换为图像。我该怎么做?我在网上找不到任何有帮助的东西。

尝试将您的google图表转换为位图,并将其设置为图像到imageview

例如:

Bitmap bitmap = loadChart("your google image url");
负荷图法

private Bitmap loadChart(String urlRqs) {
        Bitmap bm = null;
        InputStream inputStream = null;

        try {
            inputStream = OpenHttpConnection(urlRqs);
            bm = BitmapFactory.decodeStream(inputStream);
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return bm;
    }
OpenHttpConnection

private InputStream OpenHttpConnection(String strURL) throws IOException {

        InputStream is = null;
          URL url = new URL(strURL);
          URLConnection urlConnection = url.openConnection();

          try{
           HttpURLConnection httpConn = (HttpURLConnection)urlConnection;
           httpConn.setRequestMethod("GET");
           httpConn.connect();

           if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
            is = httpConn.getInputStream(); 
           }
          }catch (Exception ex){
              Log.e("###","",ex);
          }

        return is;
    } 
最后,您可以使用以下代码将位图设置为图像视图背景

image.setImageBitmap(bitmap);
试试看。 我希望这对你有帮助