簡體   English   中英

錯誤:在包“ android”中找不到屬性“ layout_width”的資源標識符:(

[英]error : no resource identifier found for attribute 'layout_width' in package 'android' :(

我剛剛開始學習應用程序開發,但我不知道為什么會顯示此錯誤...有人可以幫忙..兩個按鈕均顯示該錯誤。

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

     <TextView
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="Your total is 0"
         android:textSize="45sp"
         android:layout_gravity="center"
         android:gravity="center"
         android:id="@+id/tvDisplay"
         />

     <Button
        android:layout_width="250sp"
        android:layout_gravity="center"
        android:layout_height="wrap_content"
        android:layout_length="wrap_content"
        android:text="Add One" 
        android:id="@+id/bAdd"
        />

    <Button
        android:layout_width="250sp"
        android:layout_gravity="center"
        android:layout_height="wrap_content"
        android:layout_length="wrap_content"
        android:text="Subtract One" 
        android:id="@+id/bSub"
        />

</LinearLayout>

我在您的布局資源中看到了一些問題。

如果要指定特定的寬度,則應使用dp而不是sp。 后者用於文本。 檢查文檔 :)

我認為不起作用的另一件事是“ android:layout_length”屬性。 我認為這不是有效的財產。 您想達到什么目的?

我希望這能解決您的問題。

暫無
暫無

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

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