Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 布局上下跳跃_Java_Android_Xml - Fatal编程技术网

Java 布局上下跳跃

Java 布局上下跳跃,java,android,xml,Java,Android,Xml,我在android活动布局中遇到问题。我有一个文本视图,其中有一个HTML格式的公式,当用户按下“上一步”或“下一步”按钮时,公式会发生变化。奇怪的问题是,当所有eq系数都为正时,当eq至少有一个负系数时,所有控件都会跳起来返回。如果有人能就我的问题提出建议,我将不胜感激 XML布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ap

我在android活动布局中遇到问题。我有一个文本视图,其中有一个HTML格式的公式,当用户按下“上一步”或“下一步”按钮时,公式会发生变化。奇怪的问题是,当所有eq系数都为正时,当eq至少有一个负系数时,所有控件都会跳起来返回。如果有人能就我的问题提出建议,我将不胜感激

XML布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/grid_bg"
    android:orientation="vertical"
    android:weightSum="100" >

    <TextView
        android:id="@+id/eqTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_weight="10"
        android:gravity="center"
        android:textColor="@color/blue"
        android:textSize="60dp" />


    <LinearLayout
        android:id="@+id/xLinearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_weight="12"
        android:gravity="center"
        android:orientation="horizontal"
        android:weightSum="100" >

        <TextView
            android:id="@+id/x1TextView"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginLeft="15dp"
            android:gravity="center"
            android:textColor="@color/black"
            android:textSize="60sp"
            android:textStyle="italic" />

        <EditText
            android:id="@+id/x1EditText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="20"
            android:background="@color/white"
            android:textColor="@color/blue"
            android:textSize="60sp" />

        <TextView
            android:id="@+id/x2TextView"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_marginLeft="50dp"
            android:gravity="center"
            android:textColor="@color/black"
            android:textSize="60sp"
            android:textStyle="italic" />

        <EditText
            android:id="@+id/x2EditText"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="20"
            android:background="@color/white"
            android:textColor="@color/blue"
            android:textSize="60sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_weight="12"
        android:gravity="center"
        android:orientation="horizontal"
         >

        <Button
            android:id="@+id/prevButton"
            android:background="@drawable/prev_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="60dp"
            android:text="@string/prevButton"
            android:textColor="@color/white"
            android:textSize="37sp" >

        </Button>

        <Button
            android:id="@+id/nextButton"
            android:background="@drawable/prev_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="60dp"
            android:text="@string/nextButton"
            android:textColor="@color/white"
            android:textSize="37sp" >

        </Button>

        <Button
            android:id="@+id/finButton"
            android:background="@drawable/fin_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            android:text="@string/finButton"
            android:textColor="@color/white"
            android:textSize="37sp" >
        </Button>
    </LinearLayout>

</LinearLayout>

如果提供的代码不够,请告诉我问题已解决。问题似乎是长负号,因为它在textview上下添加了额外的空白

eq.userAns[eq.counter][0] = x1EditText.getText().toString();
eq.userAns[eq.counter][1] = x2EditText.getText().toString();
eq.counter--;
nextButton.setEnabled(true);
nextButton.setAlpha(1);
eqTextView.setText(Html.fromHtml(eq.equations[eq.counter]));
if (eq.counter == 0) {
        prevButton.setEnabled(false);
        prevButton.setAlpha((float) 0.5);
}
x1EditText.setText(eq.userAns[eq.counter][0]);
x2EditText.setText(eq.userAns[eq.counter][1]);
x1EditText.requestFocus();