2015-08-19 35 views
0

這是在Android Studio中包含我的錯誤的代碼。Android Studio Drawable Folder

錯誤說

渲染問題注:此項目包含資源的錯誤,所以AAPT沒有成功,這可能會導致渲染失敗。首先解決資源問題。

Couldn't resolve resource @drawable/chrysanthemum 

下面是我在類型activity_main.xml中

<RelativeLayout 
    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:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity"> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/chrysanthemum" 
    </ImageView> 

     </RelativeLayout> 

請幫我解決這個難題的代碼。這實際上是我第一次使用Android Studio。我對這個軟件真的很陌生。

+0

檢查我的答案 –

+0

爲什麼不正確關閉ImageView標記? –

+0

我編輯它,仍然是相同的,但它提供了一個新的音符錯誤 無法將drawable/tulipsflower轉換爲可繪製的 – len

回答

1

嘗試這種方式,就像重建和清理項目。然後

文件→無效緩存/重啓→只需重新啓動。 呵呵一兩件事。其你最大的錯誤。請關閉您的ImageView標籤像這樣,

<ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/chrysanthemum" 
    /> 
1

我想你錯過了「>」字符:

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:src="@drawable/chrysanthemum"> 
</ImageView> 
+0

此外,根本不需要顯式結束標籤。你可以像這樣關閉View標籤:'/>' –

0

修正你的XML代碼。添加結束標籤到您的ImageView:

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:src="@drawable/chrysanthemum" /> 
相關問題