0

I have added a picture to an imageView. I can see the picture in my preview, but when I run the application, it just displays a red square. The image has a size of 256 × 256. Here is the code

 <ImageView
        android:layout_gravity="center"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:src="@mipmap/dicepic"/>

Image of dice game

enter image description here

vm345
  • 813
  • 12
  • 28
  • Check the preview with different screen densities or sizes – Lance Toth Feb 27 '18 at 10:26
  • Can you try setting it programmatically: `img.setImageResource(R.mipmap. dicepic);` – Ryan Feb 27 '18 at 10:43
  • It also looks like you may be experiencing a scaling problem. You could also take a look at this answer and see if it helps: https://stackoverflow.com/questions/8232608/fit-image-into-imageview-keep-aspect-ratio-and-then-resize-imageview-to-image-d – Ryan Feb 27 '18 at 10:50
  • Thanks, that fixed it! – Edwin Mhoy Silva Feb 27 '18 at 11:05
  • 1
    don't put regular drawables in mipmap. Mipmap is only for app launcher icons – Tim Feb 27 '18 at 11:23

0 Answers0