Firstly I am a beginner, learning to code by myself. I am using Visual Studio Xamarin to create an android app. I am trying to put assign an image called logo.png to an imageview. I do not have a drawable file under the Resources file so I added a folder, named it 'drawable'. I then pasted the logo.png. The xml code for the imageview:
<ImageView
android:src="@android:drawable/logo.png"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView1" />
I have not modified any java/ C# files. Some of the unusual folders that I have under resources include mipmap-anydpi, mipmap-hdpi, mipmap-mdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi. I tried having the logo.png on all these folders and tried to build with the same xml code but no improvements. (btw I nearly do not know any xml). and in this case it says activity_main.axml compared to how it is on the Android Studio which has the name activity_main.axml. Does this have anything to do with the problem? I am following this tutorial by the way: https://youtu.be/WBTZ7TSan_E
If you puted the logo.png
:
on src/drawable/ use @drawable/logo.png
if on src/mipmap/ use @mipmap/logo.png
Why not @android:
?
This path point to android resources, are default files, belongs to Android SDK
Android OS has its own resources, like color variables, default dimensions, themes etc.
If you use some internal drawable resources that exist in your phone, then you use:
android:src="@android:drawable/..."
If you use the resources that you add in your app, in your folder drawable
, then use:
android:src="@drawable/..."
It's important to remember that, as you will run into that quite often.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.