2017-07-24 48 views
0

我是新来的XML,我无法过去“多根标签”错误,我已经读过其他问题,但似乎没有工作,我该如何解决它?多根标签Android Studio

<?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> 
+2

有什么错误? –

+0

在此处添加出现在android studio中的日志,以查看代码中发生了什么... – DarckBlezzer

回答

0

您的布局应该是这样的:

<?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> 
0

您的布局只能有一个顶级标签。你目前有两个(ConstraintLayout和LinearLayout)。可能你并不是想用/>来结束ConstraintLayout标签;删除斜线并在文件底部添加结束标记。