ScrollView中的XYPlot(AndroidPlot库)未显示
我正在尝试将ScrollView中的XYPlot(AndroidPlot库)未显示,android,scrollview,androidplot,Android,Scrollview,Androidplot,我正在尝试将XYPlot(来自AndroidPlot库)放入ScrollView容器中,因为此活动中会有更多内容。不幸的是,我得到的只是空白,图表应该出现在空白处(当我删除ScrollView时,它会正确显示) 我的布局xml文件: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:
XYPlot
(来自AndroidPlot库)放入ScrollView
容器中,因为此活动中会有更多内容。不幸的是,我得到的只是空白,图表应该出现在空白处(当我删除ScrollView
时,它会正确显示)
我的布局xml文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
androidPlot.title="A Simple XY Plot"
androidPlot.domainLabel="Domain"
androidPlot.rangeLabel="Range"
androidPlot.titleWidget.labelPaint.textSize="@dimen/title_font_size"
androidPlot.domainLabelWidget.labelPaint.textSize="@dimen/domain_label_font_size"
androidPlot.rangeLabelWidget.labelPaint.textSize="@dimen/range_label_font_size"
androidPlot.graphWidget.marginTop="20dp"
androidPlot.graphWidget.marginLeft="15dp"
androidPlot.graphWidget.marginBottom="30dp"
androidPlot.graphWidget.marginRight="10dp"
androidPlot.graphWidget.rangeLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.rangeOriginLabelPaint.textSize="@dimen/range_tick_label_font_size"
androidPlot.graphWidget.domainLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.graphWidget.domainOriginLabelPaint.textSize="@dimen/domain_tick_label_font_size"
androidPlot.legendWidget.textPaint.textSize="@dimen/legend_text_font_size"
androidPlot.legendWidget.iconSizeMetrics.heightMetric.value="15dp"
androidPlot.legendWidget.iconSizeMetrics.widthMetric.value="15dp"
androidPlot.legendWidget.heightMetric.value="25dp"
androidPlot.legendWidget.positionMetrics.anchor="right_bottom"
androidPlot.graphWidget.gridLinePaint.color="#000000"/>
</LinearLayout>
</ScrollView>
这是一个来自的示例,略为截断。我已经检查了这个答案:
当我将布局更改为:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.androidplot.xy.XYPlot
android:id="@+id/mySimpleXYPlot"
android:layout_width="match_parent"
android:layout_height="match_parent" .../>
然后添加几个TextView
小部件,图表就会出现,但我无法滚动查看它们。最后,当我添加更多的TextView
小部件(像很多)时,图表不会再次出现,但我可以看到所有TextView
小部件,并滚动查看它们
有人能帮忙吗?我也有类似的问题。最痛苦的是意识到这个问题实际上包含了两个不同的问题 1.)布局定义 定义XYPlot的布局时,请定义所需的dp值,而不是
android:layout\u height=“match\u parent”
(类似于android:layout\u height=“200dp”
)
2.)硬件加速
在检查logcat时,我注意到以下输出
W/视图﹕ 视图太大,无法放入图形缓存,需要10368000字节,只有8294400可用
快速的搜索使我找到了他。因此,基本上我在AndroidManifest.xml文件中的活动中添加了android:hardwareAccelerated=“false”
。在那之后,它起了作用,但速度非常慢。最后,我在XYPlot布局定义中添加了androidplot.renderMode=“use\u background\u thread”
,这些更改对我起到了作用
希望这会有所帮助。在滚动视图中,添加
android:fillViewport=“true”
。
然后,在XYPlot中添加以下属性:
android:minWidth
android:minHeight
我已将minWidth和minHeight设置为XYPlot中的原始宽度和高度。这应该能奏效。我还手动将XYPlot的高度设置为
250dp
。我不确定这是否有什么不同。嗨,我在问题提出几天后改变了绘图库。我现在没有机会检查你的答案,所以我不能确认它是否有帮助并接受这个答案。然而,若有人有类似的问题,请添加评论,若这有帮助,我会接受这作为一个答案。嗨,我改变了图库后几天的问题被问到。我现在没有机会检查你的答案,所以我不能确认它是否有帮助并接受这个答案。然而,如果有人有类似的问题,请添加评论,如果这有帮助,我会接受这作为一个答案。
android:minWidth
android:minHeight