我在以下代码中有多个错误。下面列出的错误。任何方案?

时间:2016-04-16 05:34:54

标签: java android android-layout layout

我在第21行出现错误“此LinearLayout布局或其FrameLayout父版本无效”,并在第29行和第30行中出现错误“LinearLayout中的无效布局参数:layout_centerHorizo​​ntal”。

<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"
tools:context=".MainActivity" >

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
    <fragment android:id="@+id/peta"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment"/>
</FrameLayout>

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="96dip"
        android:orientation="vertical"
        android:weightSum="2" >
        <Spinner
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:id="@+id/spinner_list_smk">
        </Spinner>
    </LinearLayout>
</FrameLayout>

1 个答案:

答案 0 :(得分:0)

您的嵌套布局不必要。只需删除线性布局。

你也看到了这个错误 LinearLayout中的布局参数无效:layout_centerHorizo​​ntal“ 因为它不是可以在框架布局中使用的属性。

只需删除线性布局标记,并将微调框作为框架布局的直接子项。