我的Android搞砸了我的文字视图

时间:2013-09-09 05:27:03

标签: android relativelayout

我正在使用相对布局,我正在试图找出为什么我的textViews搞乱了。以下是它如何开始(点击放大)

enter image description here

但是当它出现的价值明星看起来像这样

enter image description here

这是我的xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="@string/inputVariables"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="84dp"
    android:text="@string/startingPoint"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/TextView01"
    android:layout_centerVertical="true"
    android:text="@string/calculatedPoint"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/speed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignBottom="@+id/textView3"
    android:layout_alignLeft="@+id/heading"
    android:text="TextView" />

<TextView
    android:id="@+id/textView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView1"
    android:layout_below="@+id/TextView02"
    android:layout_marginTop="14dp"
    android:text="@string/oneSecond" />

<TextView
    android:id="@+id/textView10"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView9"
    android:layout_below="@+id/textView8"
    android:layout_marginTop="25dp"
    android:text="@string/tenMilliSecond" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView9"
    android:layout_below="@+id/textView1"
    android:layout_marginLeft="17dp"
    android:layout_marginTop="16dp"
    android:text="@string/heading" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView7"
    android:layout_below="@+id/textView2"
    android:text="@string/speed" />

<TextView
    android:id="@+id/oneSecondCalculatedPointLongitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView10"
    android:layout_alignLeft="@+id/oneSecondCalculatedLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:layout_below="@+id/textView9"
    android:layout_marginTop="16dp"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/oneHundredMillisecondLatitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/oneSecondCalculatedPointLongitude"
    android:layout_below="@+id/textView10"
    android:layout_marginTop="18dp"
    android:text="TextView" />

<TextView
    android:id="@+id/textView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/oneHundredMillisecondLatitude"
    android:layout_alignBottom="@+id/oneHundredMillisecondLatitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/oneHundredMillisecondLongitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/oneHundredMillisecondLatitude"
    android:layout_below="@+id/oneHundredMillisecondLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/textView12"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/oneHundredMillisecondLongitude"
    android:layout_alignBottom="@+id/oneHundredMillisecondLongitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/textView8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView7"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView5"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/longitude" />

<TextView
    android:id="@+id/startingPointLatitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/speed"
    android:layout_below="@+id/TextView01"
    android:layout_marginTop="26dp"
    android:text="TextView" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/startingPointLatitude"
    android:layout_alignBottom="@+id/startingPointLatitude"
    android:layout_toLeftOf="@+id/heading"
    android:text="@string/latitude" />

<TextView
    android:id="@+id/startingPointLongitude"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView6"
    android:layout_alignBottom="@+id/textView6"
    android:layout_alignLeft="@+id/startingPointLatitude"
    android:text="TextView" />

<TextView
    android:id="@+id/oneSecondCalculatedLatitude"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView8"
    android:layout_alignLeft="@+id/startingPointLongitude"
    android:text="TextView" />

<TextView
    android:id="@+id/heading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/textView2"
    android:layout_alignBottom="@+id/textView2"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/textView2"
    android:text="TextView" />

这是我的代码,它改变了textView.texts

                    Location predicationPoint = DOTGpsAppUtils.predictionAlgorithm(latitude, longitude, 1, 100);

                double predictionLongitude = (longitude + predicationPoint.getLongitude())/2;
                double predictionLatitude = (latitude + predicationPoint.getLatitude())/2;

                TextView textView = (TextView) findViewById(R.id.oneHundredMillisecondLatitude);
                textView.setText(Double.valueOf(predictionLatitude).toString());

                textView = (TextView) findViewById(R.id.oneSecondCalculatedPointLongitude);
                textView.setText(Double.valueOf(predictionLongitude).toString());


                if(x == 9)
                {
                    longitude = predictionLongitude;
                    latitude = predictionLatitude;
                }

                System.out.println(x);

                ++x;
            }while(x < 10);

            TextView textView = (TextView) findViewById(R.id.startingPointLongitude);
            textView.setText(Double.valueOf(location.getLongitude()).toString());

            textView = (TextView) findViewById(R.id.startingPointLatitude);
            textView.setText(Double.valueOf(location.getLatitude()).toString());

            textView =  (TextView) findViewById(R.id.oneSecondCalculatedPointLongitude);
            textView.setText(Double.valueOf(longitude).toString());

            textView = (TextView) findViewById(R.id.oneSecondCalculatedLatitude);
            textView.setText(Double.valueOf(latitude).toString());

1 个答案:

答案 0 :(得分:0)

对我而言,看起来您将值分配给错误的TextViews。