2016-07-18 6 views
0

Я рассмотрел другие подобные вопросы по этой проблеме, но, похоже, ничто не кажется таким же плохим, как у меня. Это код из моего res/layout/activity_signup.xml. Ошибка продолжает отображаться рядом с первой скобкой. Какую глупость я пропущу на этот раз?Продолжайте получать ошибку «Несколько корневых тегов»

<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:context="co.jessicagallego.neo.SignupActivity"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:popupTheme="@style/AppTheme.PopupOverlay" /> 

</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_signup" /> 

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    android:src="@android:drawable/ic_dialog_email" /> 

</android.support.design.widget.CoordinatorLayout> 

<ScrollView> 
<LinearLayout 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:paddingTop="56dp" 
android:paddingLeft="24dp" 
android:paddingRight="24dp"> 

<ImageView android:src="@drawable/logo" 
    android:layout_width="wrap_content" 
    android:layout_height="72dp" 
    android:layout_marginBottom="24dp" 
    android:layout_gravity="center_horizontal" /> 

<!-- Name Label --> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp"> 
    <EditText android:id="@+id/input_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textCapWords" 
     android:hint="Name" /> 
</android.support.design.widget.TextInputLayout> 

<!-- Email Label --> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp"> 
    <EditText android:id="@+id/input_email" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textEmailAddress" 
     android:hint="Email" /> 
</android.support.design.widget.TextInputLayout> 

<!-- Password Label --> 
<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="8dp"> 
    <EditText android:id="@+id/input_password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textPassword" 
     android:hint="Password"/> 
</android.support.design.widget.TextInputLayout> 

<!-- Signup Button --> 
<android.support.v7.widget.AppCompatButton 
    android:id="@+id/btn_signup" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="24dp" 
    android:layout_marginBottom="24dp" 
    android:padding="12dp" 
    android:text="Create Account"/> 

<TextView android:id="@+id/link_login" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="24dp" 
    android:text="Already a member? Login" 
    android:gravity="center" 
    android:textSize="16dip"/> 

</LinearLayout> 
</ScrollView> 

ответ

0

По-видимому, у вас есть два корня теги в XML, то первый из них является CoordinatorLayout и второй из них является ScollView.

Android SDK поддерживает только один тег root в вашем XML. Чтобы устранить эту проблему, вы можете объединить обе метки, которые вы используете в одном корневом теге так:

<RelativeLayout> 

    <CoordinatorLayout> 
    </CoordinatorLayout> 

    <ScrollView> 
    </ScrollView> 

</RelativeLayout> 

Или вы можете поместить один из корневых тегов внутри другой в соответствии с тем, как вы хотите создать свой вид, например:

<CoordinatorLayout> 

    <ScrollView> 
    </ScrollView> 

</CoordinatorLayout>