android - Dummy ImageView not showing image -
android - Dummy ImageView not showing image -
it showing image in android studio preview doesn't show when i'm running on device. ideas why happens? what's wrong code?
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/myimage" /> </relativelayout>
in add-on comment i've added few possible soultions. unusual image isn't showing already. show in imageview in xml gui design view?
anyway here 2 possible solutions: xml:
<imageview android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/myimage" /> also imageview hasn't been assigned id seems weird needed sec idea:
<imageview android:id="@+id/image_id" android:layout_width="match_parent" android:layout_height="match_parent" /> java side:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //what ever name of activity using image= (imageview)findviewbyid(image_id); image.setimageresource(image_id); } lets hope helps!
edit
<imageview android:scaletype="fitxy" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/myimage" /> note fitxy may lower quality of image. seek messing other scale types
android imageview
Comments
Post a Comment