android - 尝试拍摄 https ://github. com/appsthatmatter/GraphView 的图表快照时出现 IllegalStateException

标签 android android-graphview

我正在尝试拍摄 GraphView 的快照,但它给出了错误“GraphView 必须在硬件加速模式下使用”。 我正在使用以下代码来拍摄快照

Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); 
Canvas canvas = new Canvas(bitmap); 
view.draw(canvas);

此外,我已经在应用程序级别设置了 android:hardwareAccelerated="true"

最佳答案

我用过这个:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:23.1.1'
 compile files('libs/GraphView-4.0.1.jar')
  compile 'com.jjoe64:graphview:4.1.0'
}

特别是

compile 'com.jjoe64:graphview:4.1.0'

这对我有帮助。

关于android - 尝试拍摄 https ://github. com/appsthatmatter/GraphView 的图表快照时出现 IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41920458/

相关文章:

android - MPAndroidChart - 折线图 - 缩小没有 X 值的图形部分

android - 将动画从屏幕顶部翻译到屏幕中间

java - 小部件 ID 和 Intent

java - 在模块 graphview 中发现重复的类

android - 如何用字符串替换Bar GraphView底部的数字?

android - GraphView 轴标签

android - 升级后 App 中的 VerifyError

java - 向特定接收者发送有序广播?

android - Android 的 invalidate() 和 postInvalidate() 方法有什么区别?