简体   繁体   English

Android的LinearLayout XML错误

[英]LinearLayout XML error Android

I'm trying to fix this so badly but I couldn't find where I've gone wrong. 我正在努力解决这个问题,但是找不到错误的地方。

The message: 消息:

Element type "LinearLayout" must be followed by either attribute specifications, ">" or "/>".

Why do I get this? 为什么我得到这个? Any ideas? 有任何想法吗?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:weightSum="100"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"

    **<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="70"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="#0000FF"
        android:padding="20dp"
        android:paddingBottom="10dp"
        android:gravity="center_horizontal">



    </LinearLayout>


</LinearLayout>

It's a pretty self-explanatory error message. 这是一个非常不言自明的错误消息。

You didn't close your LinearLayout tag. 您没有关闭LinearLayout标签。 Add a > after android:orientation="vertical" . android:orientation="vertical"之后添加一个>

You missed a ">" at the end: 您在末尾错过了一个“>”:

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

Your first LinearLayout tag isn't closed. 您的第一个LinearLayout标签没有关闭。 Add a > to the end of it, like this: 在其末尾添加一个> ,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:weightSum="100"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

                                   ^

Error clearly states that you missed the closing tag. 错误明确指出您错过了结束标签。 Every Layout and its attribute needs to have their own opening and closing tag. 每个布局及其属性都需要有自己的开始和结束标签。 Add

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="70"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
/>

or 要么

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="70"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

</LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM