Search code examples
android-studioimageviewandroid-imageviewimage-size

How to select the ideal image size for any screen?


I am trying to insert the images into the screen but when I insert some large image it gives the error of "too large bit image" and when I insert a small image like 400 x 400 pixels it gets blurred. How to select the exact image size so that it looks good (not blurred).

here is the code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".MainActivity2">
     <ImageView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:src="@drawable/non"
         android:scaleType="centerCrop">

     </ImageView>

Solution

  • You can either use a vector image or use different sizes of your raster image for each dpi.

    I would suggest going for vector if you can because it's simpler & lighter but if you cant use a vector image, this will guide you.