Jeferson Borba Jeferson Borba - 3 years ago 319
Android Question

Multiple Root Tags Android Studio

i'm new to xml, and i can't get past "Multiple Root Tags" error, i`ve read others questions, but nothing seems to work, how can i fix it?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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" />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@strig/quantity"
android:textAllCaps="true"
android:textColor="@android:color/darker_gray"
android:textSize="16sp"
android:textStyle="bold" />

</LinearLayout>

Answer Source

Your layout should be like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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" >

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:text="@strig/quantity"
android:textAllCaps="true"
android:textColor="@android:color/darker_gray"
android:textSize="16sp"
android:textStyle="bold" />

</LinearLayout>
</android.support.constraint.ConstraintLayout> 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download