2015-08-22 48 views
0

我正在製作一個應用程序,並且由於它最近有很大改進,我已經轉移到了Android Studio 1.3.1。我在activity_main.xml中有一行ImageButtons。然後我右鍵點擊drawable文件夾選擇NewImageAsset。我已嘗試資產類型Launcher Icons,Action Bars and Tab IconsNotification Icons並選擇了一張圖片。 Android Studio渲染圖像的hdpi,mdpi,xhdpi和xxhdpi版本。將圖像添加到Android Studio 1.3.1項目

但仍然android:src="@drawable/backwardImage給我Cannot resolve android:src="@drawable/backwardImage"

你如何在android studio 1.3.1中做到這一點?我很確定有一個非常簡單的答案。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_weight=".10" 
     android:orientation="horizontal"> 
     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/backwardImage" 
      android:id="@+id/imageButton01"/> 
     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/backwardImage" 
      android:id="@+id/imageButton02"/> 
     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/backwardImage" 
      android:id="@+id/imageButton03"/> 
    </LinearLayout> 

問候,

托馬斯

回答

1

我沒試過你的方式。

使用資源管理器,轉到源代碼,將我的圖像粘貼到可繪製文件夾中。轉到Android工作室,您將看到圖像(與drawable-xhdpi等相同)

另一種方法是將您的圖像從資源管理器拖到Android工作室中的繪圖工具。

注意:您的圖片應該是png或jpg。希望這個幫助!

0

好吧,經過2天的尋找,我終於找到了這個proj_name/app/src/main/res/drawable-folder。我只將名稱改爲小寫,實際上它起作用! Tomas

+0

很好聽。 –