首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在AndroidPlot中未呈现AndroidPlot xml

在AndroidPlot中未呈现AndroidPlot xml
EN

Stack Overflow用户
提问于 2015-11-21 22:06:34
回答 2查看 471关注 0票数 0

AndroidPlot XYPlot不会在xml预览中呈现。我使用的是AndroidPlot 0.6.1。我把罐子放在我的唇夹里了。我在Gradle脚本中把它作为依赖项。此外,我还能够编译、运行应用程序并查看图表。

但是,为了看到简单的视觉变化,不得不运行这个应用程序是非常乏味的。我看了Maven快速启动视频,我看到创建者尼克·费罗斯能够看到预览。

以下是预览版中的堆栈跟踪:

java.lang.AssertionError at android.content.res.BridgeResources.getDimension(BridgeResources.java:345) at com.androidplot.util.Configurator.parseFloatAttr(Configurator.java:145) at com.androidplot.util.Configurator.inflateParams(Configurator.java:236) at com.androidplot.util.Configurator.configure(Configurator.java:322) at com.androidplot.util.Configurator.configure(Configurator.java:286) at com.androidplot.Plot.loadAttrs(Plot.java:371) at com.androidplot.Plot.init(Plot.java:316) at com.androidplot.Plot.<init>(Plot.java:249) at com.androidplot.xy.XYPlot.<init>(XYPlot.java:150) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105) at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:214) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:142) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64) at android.view.LayoutInflater.rInflate(LayoutInflater.java:782) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:385) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:413) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485) at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590) at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request$1.run(Alarm.java:351) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

我注意到,每当我删除自定义xml属性(下面),我就可以预览图形。这意味着,虽然,我不能用我想要的方式在预览图的样式。

androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size" androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size" androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"

在进一步的研究中,我还注意到,只有当xml属性被设置为与其他资源相等的时候(例如=“@dimen/title_ the _size”或...title="@string/test_string“),才会发生这种情况。如果预览为=“15 it”和"test“,则预览可以正常工作。预览适用于硬编码项。如何使用资源参数进行预览?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-12-05 23:49:01

首先,您肯定不希望在将jar作为Gradlee依赖项包含在您的libs dir中。我建议你继续坚持梯度依赖。

至于您的问题,Configurator并不总是能很好地处理IDE预览,也不能保证工作正常。好消息是刚刚发布了一个新版本的库(0.9.3),其中包括许多新的可样式的吸引,包括您列出的项目的吸引。更新您的依赖关系,然后:

代码语言:javascript
复制
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"

变成:

代码语言:javascript
复制
ap:labelTextSize="@dimen/title_font_size"
ap:rangeLabelTextSize="@dimen/range_label_font_size"
ap:legendTextSize="@dimen/legend_text_font_size"
票数 0
EN

Stack Overflow用户

发布于 2015-11-22 04:10:02

AndroidPlot XYPlot正在运行gradle版本

代码语言:javascript
复制
dependencies {
    compile 'com.androidplot:androidplot-core:0.6.1'
}

在项目中添加库

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33849133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档