If you're wracking your brain trying to figure out why that ImageView isn't displaying the drawable (and you know the drawable's there), make sure and check that you have specified the namespace prefix for the "src" attribute.
Android will silently ignore an attribute like src="@drawable/image_I_know_exists", when you really need to be specifying android:src="@drawable/image_I_know_exists", assuming you've got something like this defined previously in your XML: xmlns:android="http://schemas.android.com/apk/res/android"
To recap:
Image will NOT show (but no error messages or anything):
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
src="@drawable/image_I_know_exists"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
Image WILL show:
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/image_I_know_exists"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
Yes, that's a bit of clutter. I know folks rant against the layout approach in Android, but it is really convenient when you really need to get under the hood, but that's another story.
No comments:
Post a Comment