Reputation: 85
The decimals on my Y axis are being covered by white spaces.
Reference below.
Here is my GraphView XML code.
<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>
These are the functions I used.
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);
Increasing the layout_margin does not change anything. It just makes the whole graph smaller instead.
Is there a way to add some left padding so that I can see the whole decimal on my Y axis?
Upvotes: 0
Views: 592
Reputation: 85
After messing around with the functions, I've found a solution. Apparently you can set the label padding by using getGridLabelRenderer.setPadding().
graph.getGridLabelRenderer().setPadding(40);
Upvotes: 2