使用PhilJay / MPAndroidChart,我如何截取整个图表的屏幕截图,而不仅仅是可见的内容?



如何获得整个图表的位图,而不仅仅是可见的位图?我试过图表。getChartBitmap((;和chart.saveToGallery("filename"(;虽然它们都可以工作,但它们只捕获用户可见的内容。我希望捕获整个图表,而不管它对用户的可见性如何。请帮忙。非常感谢。

我不知道这个答案是否会被破解。但它对我有效。我只是想明白了。

<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="horizontal">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" >
<com.github.mikephil.charting.charts.CombinedChart
android:id="@+id/combinedChartBroodingGrowing"
android:layout_width="3000dp"
android:layout_height="1000dp"
/>
</LinearLayout>
</HorizontalScrollView>

不幸的是,您需要明确指定layout_width和layout_height才能正常工作(您需要反复考虑并决定什么对您最有利。此外,请注意:我没有检查任何副作用。请谨慎使用。非常抱歉!(。还要确保未设置setVisibleXRangeMaximum()。然后像往常一样调用saveToGallery()。您将看到整个图表保存到库中。:(

相关内容

最新更新