由于我从layout_weightsum更改为weightsum,我得到权重错误

时间:2015-02-14 09:29:48

标签: android android-layout android-layout-weight

我将9个图像分成3行,如3X3矩阵。我们在提供layout_weightsum时遇到错误,所以我把它改成了weightum。它还在向我显示错误。我正在使用Andorid Studio。

以下是我的代码。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/third_screen">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scroll_screen3"
        android:layout_alignParentTop="true"
        >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/retreat_2"
        android:id="@+id/screen3_view">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="CHOOSE YOUR RETREAT"
            android:id="@+id/txt_welcome"
            android:focusableInTouchMode="false"
            android:layout_gravity="center_horizontal"
            android:textSize="20sp"
            android:textColor="#ffffffff"
            android:layout_marginTop="20dp"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="10dp"
            android:gravity="center_horizontal" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:id="@+id/hover"
            android:src="@drawable/hover"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="10dp" />

        <LinearLayout
            android:background="@drawable/outline1"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="418dp"
            android:layout_margin="20dp"
            android:weightsum="3"
            android:id="@+id/outline_pockets" >

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:id="@+id/first_line_pockets"
                android:layout_weightsum="3"
                android:layout_weight="1"
                android:layout_marginTop="10dp">

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket11"
                    android:src="@drawable/img1"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket12"
                    android:src="@drawable/img2"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket13"
                    android:src="@drawable/img3"
                    android:layout_weight="1" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/first_line_txt"
                android:layout_gravity="center_vertical"
                android:weightsum="3" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="UNREASONABLE JOY"
                    android:layout_gravity="center_horizontal"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:gravity="center_vertical|center_horizontal"
                    android:textSize="13sp"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket11" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="LIGHTEN  UP"
                    android:layout_gravity="center_horizontal"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:gravity="center_vertical|center_horizontal"
                    android:textSize="13sp"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket12" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="RELEASING DISEASE"
                    android:id="@+id/txt_pocket13"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_vertical|center_horizontal"
                    android:textSize="13sp"
                    android:textIsSelectable="false"
                    android:layout_weight="1" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/second_line_pockets"
                android:weightsum="3"
                android:layout_weight="1">

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket21"
                    android:src="@drawable/img4"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket22"
                    android:src="@drawable/img5"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket23"
                    android:src="@drawable/img6"
                    android:layout_weight="1" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:id="@+id/second_line_txt"
                android:weightsum="3" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="BEYOND FEVER"
                    android:autoText="false"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:textSize="13sp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket21" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="UNSHAKEABLE LOVE"
                    android:layout_gravity="center_horizontal"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:textSize="13sp"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket22" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="PEACEFUL PARENTING"
                    android:textSize="13sp"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:layout_gravity="center_horizontal"
                    android:gravity="center_vertical|center_horizontal"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket23" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/third_line_pockets"
                android:weightsum="3"
                android:layout_weight="1">

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket31"
                    android:src="@drawable/img7"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket32"
                    android:src="@drawable/img8"
                    android:layout_weight="1" />

                <ImageView
                    android:layout_width="60dp"
                    android:layout_height="80dp"
                    android:id="@+id/pocket33"
                    android:src="@drawable/img9"
                    android:layout_weight="1" />
            </LinearLayout>

            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/third_line_txt"
                android:weightsum="3"
                android:layout_marginBottom="10dp" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="GETTING UNSTUCK"
                    android:autoText="false"
                    android:layout_gravity="center_vertical"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:gravity="center_vertical|center_horizontal"
                    android:textIsSelectable="false"
                    android:textSize="13sp"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket31" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="WARRIOR MONK"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:layout_gravity="center_vertical"
                    android:gravity="center_vertical|center_horizontal"
                    android:textSize="13sp"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket32" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="50dp"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="FILLING YOUR CUP"
                    android:lines="2"
                    android:textAlignment="center"
                    android:textColor="#FFFFFF"
                    android:layout_gravity="center_vertical"
                    android:gravity="center_vertical|center_horizontal"
                    android:textSize="13sp"
                    android:singleLine="false"
                    android:layout_weight="1"
                    android:id="@+id/txt_pocket33" />
            </LinearLayout>
        </LinearLayout>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:id="@+id/no_more"
            android:src="@drawable/no_more"
            android:layout_marginTop="10dp" />

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:id="@+id/retreat_quiz"
            android:src="@drawable/retreat_quiz"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="20dp"
            android:layout_marginBottom="20dp" />

    </LinearLayout>
    </ScrollView>

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

该属性的正确拼写为weightSum,而不是weightsumlayout_weightsum

但是,系统可以为您计算总和。您可以完全省略该属性。