0

I add a graphview programatically :

    LinearLayout.LayoutParams Lparams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, p.y/2);

//same result with fill_parent or match_parent

    Lparams.gravity = Gravity.LEFT;

    firstGraph.setPadding(10, 0, 10, 0);

    firstGraph.setLayoutParams(Lparams);

    LinearLayout RelLayout = (LinearLayout) findViewById(R.id.relLayout);

    RelLayout.setGravity(Gravity.LEFT);
    RelLayout.addView(firstGraph, 0);

I obtain this: Problem

What i want is to eliminate that left gap of the graphview, I don't know why is there, I only set a padding of 10 that is what you have in right side.

Any Suggestions? Thansk in advance.

the layout xml:

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="left"
        android:orientation="vertical" >

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />



</LinearLayout>
4

2 回答 2

1

该空间很可能出现,因为它是为轴标签保留的空间(并且您可能没有设置任何标签,它是一个空白空间)。如果确实需要删除它,则必须修改图形视图的代码并更改其中的值GraphViewConfig(因为那些似乎是使用的值)。

于 2012-08-29T11:19:35.437 回答
0

setPadding(int left, int top, int right, int bottom) 是 setPadding 的语法。第一个参数用于左侧填充。你给 10。试试 setPadding(0, 0, 10, 0)

于 2012-08-27T12:12:56.117 回答