Добавить левый отступ к оси Y в GraphView - PullRequest
0 голосов
/ 01 февраля 2019

Десятичные дроби на моей оси Y закрыты пробелами.

Ссылка ниже.

graph

Вот мой код 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?

1 Ответ

0 голосов
/ 04 февраля 2019

После возни с функциями я нашел решение.По-видимому, вы можете установить заполнение метки с помощью getGridLabelRenderer.setPadding ().

graph.getGridLabelRenderer().setPadding(40);

...