将项目移动到嵌套的LinearLayout会破坏我的应用程序

时间:2013-06-08 08:16:47

标签: android android-layout android-linearlayout android-relativelayout

我正在尝试将元素(如changeTextView和daysLowTextView)从最外面的RelativeLayout移动到标记为col1,col2,col3和col4的嵌套LinearLayout元素,但我的应用程序在打开时会失败。我也删除了所有LinearLayout定位。有什么建议?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_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"
android:stretchColumns="yes"
android:background="@color/black"
tools:context=".MainActivity" >

<LinearLayout android:id="@+id/center" 
    android:layout_width="1dp" 
    android:layout_height="1dp"
    android:layout_centerHorizontal="true" 
    android:visibility="invisible"
    android:orientation="vertical"/>

<LinearLayout
    android:id="@+id/topRowLinearLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/enterSymbolTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/stock_symbol"
        android:textColor="@color/white" />

    <EditText
        android:id="@+id/stockSymbolEditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="10"
        android:inputType="text"
        android:textColor="@color/white"
        android:textCursorDrawable="@null" />

    <Button
        android:id="@+id/enterStockSymbolButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/enter_stock_symbol"
        android:textColor="@color/white" />

</LinearLayout>

<TextView
    android:id="@+id/companyNameTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/topRowLinearLayout"
    android:padding="@dimen/activity_horizontal_margin"
    android:layout_toLeftOf="@id/center"
    android:text="Company Name"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<WebView
    android:id="@+id/yahooWebView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true" />

<TextView
    android:id="@+id/daysLowTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/stock_days_low"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/yearLowTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/stock_year_low"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/daysRangeTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/days_range"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/yearHighTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/stock_year_high"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/changeTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/change"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/daysHighTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/stock_days_high"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/lastTradePriceOnlyTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@id/companyNameTextView"
    android:layout_toRightOf="@id/companyNameTextView"
    android:text="@string/last_trade_price_only"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<!-- Begin 2 columns of data -->

<LinearLayout 
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:layout_above="@id/yahooWebView">

    <LinearLayout 
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <LinearLayout 
            android:id="@+id/col1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1">


        </LinearLayout>

        <LinearLayout 
            android:id="@+id/col2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1">



        </LinearLayout>

        <LinearLayout 
            android:id="@+id/col3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1">

        </LinearLayout>

        <LinearLayout 
            android:id="@+id/col4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            android:layout_weight="1">

        </LinearLayout>
    </LinearLayout>
</LinearLayout>
<!-- end columns of data -->

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

由于某种原因,我不得不清理项目,然后自行修复。