在我的y轴的小数正在用空格覆盖。
参考下面。
这里是我的GraphView XML代码。
<android.support.v7.widget.CardView
android:id="@+id/card_view2"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_margin="20dp"
android:elevation="30dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/activity_full_screen_humid"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:layout_weight="0.8"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGrey"
android:orientation="horizontal">
<TextView
android:id="@+id/info_text2"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_weight="0.9"
android:text="@string/overall_humid"
android:textAllCaps="true"
android:textSize="15sp"
android:textStyle="bold" />
<ImageButton
android:id="@+id/fullscreen2"
android:layout_width="40dp"
android:layout_height="60dp"
android:layout_marginEnd="10dp"
android:layout_weight="0.1"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:onClick="onFullScreen"
android:scaleType="fitXY"
android:src="@drawable/fullscreen_icon" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
这是我使用的功能。
graph.getGridLabelRenderer().setLabelFormatter(new DateAsXAxisLabelFormatter(this));
graph.getGridLabelRenderer().setNumHorizontalLabels(2);
graph.getViewport().setMinX(d1.getTime());
graph.getViewport().setMaxX(d3.getTime());
graph.getViewport().setXAxisBoundsManual(true);
graph.getGridLabelRenderer().setHumanRounding(false);
增加layout_margin不会改变任何东西。它只是使整个图形,而不是更小。
有没有一种方法添加一些左填充,这样我可以看到我的Y轴全小数?
乱搞与功能之后,我已经找到了解决办法。显然,您可以通过使用getGridLabelRenderer.setPadding设置标签填充()。
graph.getGridLabelRenderer().setPadding(40);