簡體   English   中英

Android的LinearLayout XML錯誤

[英]LinearLayout XML error Android

我正在努力解決這個問題,但是找不到錯誤的地方。

消息:

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

為什么我得到這個? 有任何想法嗎?

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

這是一個非常不言自明的錯誤消息。

您沒有關閉LinearLayout標簽。 android:orientation="vertical"之后添加一個>

您在末尾錯過了一個“>”:

<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標簽沒有關閉。 在其末尾添加一個> ,如下所示:

<?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"
/>

要么

<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