簡體   English   中英

錯誤:不允許使用字符串類型(在'layout_height'中,值為'wrap content')。 activity_main.xml中

[英]Error: String types not allowed (at 'layout_height' with value 'wrap content'). activity_main.xml

我是論壇的新手,剛剛開始學習Android應用開發。 我正在閱讀developer.android.com上的教程,並且已經遇到了編譯錯誤。 我在activity_main.xml上看到了這三個錯誤:

error: Error: String types not allowed (at 'layout_height' with value 'wrap content').  activity_main.xml   
error: Error: String types not allowed (at 'layout_width' with value 'wrap content').   activity_main.xml   
error: Error: String types not allowed (at 'layout_height' with value 'wrap content').  activity_main.xml

這是我現在的activity_main.xml代碼:

<LinearLayout 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"
    android:orientation="horizontal"
    tools:context=".MainActivity" >

    <EditText android:id="@+id/edit_message"
        android:layout_width="0dp"
        android:layout_height="wrap content"
        android:layout_weight="1"
        android:hint="@string/edit_message" />

    <Button
        android:layout_width="wrap content"
        android:layout_height="wrap content"
        android:text="@string/button_send" />

</LinearLayout>

它是否會拋出錯誤,因為wrap_content是一個不正確的語法,還是需要在其他地方聲明? 任何幫助將不勝感激如何解決或修復此問題。

謝謝!

我剛開始學習自己。 我相信問題是缺少下划線。 它應該是“wrap_content”而不是“wrap content”。

這是wrap_content沒有wrap content 改變它,你的問題應該早就消失了!

必須是 wrap_content 而不是 wrap content

更改

 <EditText android:id="@+id/edit_message"
        android:layout_width="0dp"
        android:layout_height="wrap content"
        android:layout_weight="1"
        android:hint="@string/edit_message" />

    <Button
        android:layout_width="wrap content"
        android:layout_height="wrap content"
        android:text="@string/button_send" />

 <EditText android:id="@+id/edit_message"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:hint="@string/edit_message" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send" />

我在Mac上評估Xamarin時遇到了同樣的錯誤。 這是目標框架的一個問題。 我的猜測是某些早期版本的Android不支持此Xml標記中的所有值,或者Xamarin無法正確處理它,或類似的東西。 我將選項 - >構建 - >常規 - >目標框架從Android 2.1更改為Android 2.2,之后構建成功。

我正在輸入“warp_content”,這對我來說很糟糕。 這是“wrap_content”而不是“warp_content”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM