Reputation: 3
I am trying to use the Icon image provided in the drawable
folder using imageView
and src attribute but the icon is not being displayed when I run the app and even it's not showing in the emulator.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:scaleType="center"
android:adjustViewBounds="true"
android:src="@drawable/icon-chat"/>
</RelativeLayout>
I expect the image should be displayed in the imageview
. Do I need to add any other attributes in the imageView
???
Upvotes: 0
Views: 171
Reputation: 259
There is certain naming convention in naming the drawables file, so while naming your files in drawable keep in mind following two points .
1)Valid characters for naming resources is [a-z, _, 0–9] .In short all small case characters, numbers, and underscore.
2)First letter of your asset(file) name can be either _ or a small case character, it cannot be a number.
Upvotes: 1
Reputation: 236
Your icon may be of larger size. Copy it to folder drawable-xxhdpi in project explorer then try.
Upvotes: 0
Reputation: 61
You can't have a '-' in a drawable name. Rename your drawable to 'icon_chat' instead of 'icon-chat'.
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:scaleType="center"
android:adjustViewBounds="true"
android:src="@drawable/icon_chat"/>
Upvotes: 0