2015-03-24 5 views
13

को हल नहीं कर सकता है मेरे पास मेरे लेआउट में ImageView है, नीचे कोड देखें। जब मैं अपने लॉन्चर आइकन होने के लिए src विशेषता निर्धारित करने में कोशिश कर रहा हूँ, मैं निम्नलिखित त्रुटि मिलती है:प्रतीक @ drawable/ic_launcher

Cannot resolve symbol '@drawable/ic_launcher' 

ic_launcer.png मेरी ड्रॉएबल फ़ोल्डर में जोड़ा जाता है, छवि नीचे देखें। मैं अपने ImageView में अपनी छवि का संदर्भ क्यों नहीं दे सकता?

परियोजना संरचना:

Project structure

Layout.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_weight="1" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <ImageView 
      android:src="@drawable/ic_launcher" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" /> 
     </LinearLayout> 
    </LinearLayout> 
</LinearLayout> 

उत्तर

28

बदलें (आप कोई drawable फ़ोल्डर):

@drawable/ic_launcher 

करने के लिए (आप मिपमैप फ़ोल्डर का उपयोग कर रहे हैं) :

@mipmap/ic_launcher 

मिपमैप - केवल माउस के लिए इस्तेमाल किया - mipmap vs drawable folders

ड्रॉएबल - माउस

के अलावा अन्य छवियों के लिए इस्तेमाल किया इस Google blogpost के अनुसार:

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

+1

'ड्रायबल' और 'मिपमैप' फ़ोल्डरों के बीच अंतर को समझाने के लिए धन्यवाद। – Marcus

4

अपने drawable हैं mipmap, जो एप्लिकेशन-लांचर के लिए इस्तेमाल किया जाना चाहिए अंदर। drawable के रूप में आप इसे उपयोग करना चाहते हैं आप drawable/ में से एक फ़ोल्डर के अंदर उन कॉपी चाहिए

+0

मैं देख रहा हूँ अब, बदल दिया गया है चाहिए कि जब मैं एंड्रॉयड स्टूडियो अपडेट किया गया। क्या उन्हें मेरे (अभी बनाए गए) खींचने योग्य फ़ोल्डर में कॉपी करने का कोई आसान तरीका है? 'ctrl + c' और' ctrl + v' एएस के अंदर काम नहीं कर रहा है। क्या मुझे फाइल एक्सप्लोरर के साथ ऐसा करना है? – Marcus

+1

यह मैक पर काम करता है। यदि आप खिड़कियों पर नहीं हैं, तो खोल का उपयोग करें .. यह सबसे तेज़ तरीका – Blackbelt

+0

@Marcus, [shift] + [f6] फ़ोल्डर्स का नाम बदलने के लिए सबसे तेज़ तरीका है। ड्रिपेबल करने का नया तरीका मिपमैप्स हैं। –

संबंधित मुद्दे