簡體   English   中英

將圖像添加到Android Studio 1.3.1項目

[英]Adding images to Android Studio 1.3.1 projects

我正在制作一個應用程序,並且由於最近有了很大的改進,因此我已移至Android Studio 1.3.1。 我的activity_main.xml有一排ImageButtons 然后我右鍵單擊drawable文件夾,選擇NewImageAsset 我嘗試了資產類型Launcher IconsAction Bars and Tab Icons以及Notification Icons並選擇了一個圖像。 Android Studio渲染圖像的hdpi,mdpi,xhdpi和xxhdpi版本。

但仍然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>

問候,

湯瑪士

我沒有嘗試過

使用資源管理器,轉到源,將我的圖像粘貼到drawable文件夾中。 轉到Android Studio,您將看到圖像(與drawable-xhdpi等相同)

另一種方法是將圖像從資源管理器拖到Android Studio中的可繪制對象。

注意:您的圖片應為png或jpg。 希望有幫助!

好的,經過2天的查找,我終於找到了這個proj_name / app / src / main / res / drawable-folder。 我將名稱更改為僅小寫,並且實際上有效! 托馬斯

暫無
暫無

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

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