背景

2011-10-05 158 views
0

我已經創建bg3.9.png圖像使用.9.png像下面這個教程背景

http://developer.android.com/guide/developing/tools/draw9patch.html

,但是當我把它放在我的drable文件夾,並嘗試使用它,然後它給錯誤在項目 請看圖片。 enter image description here

main.xml中文件的代碼是:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:orientation="vertical" android:background="@drawable/bg3"> 
    <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/gridview" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:columnWidth="65dp" 
     android:numColumns="auto_fit" android:verticalSpacing="10dp" 
     android:horizontalSpacing="10dp" android:stretchMode="columnWidth" 
     android:gravity="center" android:layout_gravity="center_vertical|center_horizontal"/> 
</LinearLayout> 

請指導我對我做了什麼錯?

+0

讓你刪除非png圖片.9.png圖像而得名? –

+1

我也有過。將九個修補程序映像添加到可繪製文件夾會導致Eclipse無法構建您的項目。嘗試刪除文件,做一個乾淨的版本,然後嘗試添加九個補丁。有時,我不得不從頭開始重新創建九個補丁映像。 –

+0

是的,我已經從繪製文件夾中刪除非PNG圖像,但仍同樣的問題:(和現在從頭開始創建new.9.png圖像是工作,但現在我的網格視圖沒有顯示整個屏幕上了,請參閱編輯代碼 – Shruti

回答

2

這是很難看到在你的屏幕截圖的名字,但它並不像你的形象被命名爲bg.9.png,它看起來像它具有三個字母的域名(wheras代碼引用@繪製/ BG)

它不應該被命名爲bg3.9.png,應該bg.9.png

+0

使用完整的圖像URL(http://i.stack.imgur.com/IFlIf.jpg),你可以看到圖像確實是叫'bg3.9.png'。 –

+0

抱歉張貼錯誤的圖像名稱現在我已經編輯它請告訴我該怎麼辦? – Shruti

+0

問題標記爲正確,所以我想你已經解決了這個問題,否則我建議你現在清理項目(項目>清潔),然後重建它(項目>編譯)(如果該項目不被自動生成)。 – Mel