android graph-view y轴数被切掉 [英] android graph-view y axis numbers being cut out

查看:105
本文介绍了android graph-view y轴数被切掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用android studio中的graph-view库创建折线图时,垂直线上的部分数字被切掉了.有人知道如何解决这个问题吗?

When trying to create a line graph with the graph-view library in android studio part of the numbers on the vertical line are being cut out.Does anybody know how to fix this?

<com.jjoe64.graphview.GraphView
            android:layout_width="300dp"
            android:layout_height="200dip"
            android:id="@+id/graph"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_gravity="center_horizontal"
            android:nestedScrollingEnabled="false" />

final GraphView graph = (GraphView)findViewById(R.id.graph);
final LineGraphSeries<DataPoint> graphSeries = new LineGraphSeries<DataPoint>(new DataPoint[] { 
    }); // the points are added progressively`

推荐答案

我遇到了同样的问题.我目前发现的解决方法是使用以下命令在与该图关联的GridLabelRenderer中设置填充:

I had the same issue. The fix I currently found is to set the padding in the GridLabelRenderer associated with the graph with:

GraphView gv = (GraphView) findViewById(R.id.graph);
GridLabelRenderer glr = gv.getGridLabelRenderer();
glr.setPadding(32); // should allow for 3 digits to fit on screen

据我了解,graphview图默认情况下期望具有全屏宽度,因此被android应用(16dp)的默认填充所截断.在GridLabelRenderer中设置此填充值可为图形的边缘增加更多的填充,从而减少图形的实际图形区域,但为数字留出更多空间.

As I understand it, the graphview graph expects to have the full screen width by default, so it is cut off by the default padding for the android app (16dp). Setting this padding value in the GridLabelRenderer adds more padding to the graph's edges, decreasing your graph's actual graphing area but allowing more room for the numbers.

作为参考,与GridLabelRenderer关联的默认填充值为20.

For reference, the default padding value associated with the GridLabelRenderer is 20.

我想有一个更优雅的解决方案,但这就是我所能想到的.希望这对提出相同问题的任何人有所帮助.

I imagine there is a more elegant solution, but this is all I was able to come up with. Hope this helps anybody who comes up with the same issue.

这篇关于android graph-view y轴数被切掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆