Carter Harrison
Carter Harrison

Reputation: 69

ImageView images seem pixelated and low quality

My Images in ImageView are all pixelated and low quality, almost blurry. They are all 48px x 48px PNG files in my drawable folder. Here's my XML file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
    android:id="@+id/main"
    android:background="#ecf0f1">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/my_photo1"
        android:onClick="val1"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/ImageView"
        android:layout_toStartOf="@+id/ImageView" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="0"
        android:id="@+id/val"
        android:textIsSelectable="false"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textSize="60dp"
        android:textColor="#ff34495e" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/ImageView"
        android:src="@drawable/my_photo2"
        android:visibility="invisible"
        android:onClick="val2"
        android:layout_alignTop="@+id/imageView"
        android:layout_toLeftOf="@+id/imageView2"
        android:layout_toStartOf="@+id/imageView2" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView2"
        android:src="@drawable/my_photo3"
        android:visibility="invisible"
        android:onClick="val3"
        android:layout_alignTop="@+id/ImageView"
        android:layout_centerHorizontal="true" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView3"
        android:src="@drawable/my_photo4"
        android:visibility="invisible"
        android:onClick="val4"
        android:layout_alignTop="@+id/imageView2"
        android:layout_toLeftOf="@+id/imageView4"
        android:layout_toStartOf="@+id/imageView4" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView4"
        android:src="@drawable/my_photo5"
        android:visibility="invisible"
        android:onClick="val5"
        android:layout_alignTop="@+id/imageView3"
        android:layout_toLeftOf="@+id/imageView5"
        android:layout_toStartOf="@+id/imageView5" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView5"
        android:src="@drawable/my_photo6"
        android:visibility="invisible"
        android:onClick="val6"
        android:layout_alignTop="@+id/imageView4"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:text="Cup Cakes"
        android:id="@+id/textView"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@+id/imageView"
        android:layout_toStartOf="@+id/imageView"
        android:textColor="#ff34495e" />

</RelativeLayout>

Upvotes: 2

Views: 9114

Answers (1)

CommonSenseCode
CommonSenseCode

Reputation: 25359

There are different directories for different image sizes. Remember that png images aren't as as SVG which use vectors to resize to different size, png are rather fixed size so when android uses your app in a bigger screen size or a small size such it uses automatic software to resize the image that is why it seems fuzzy.

Open your src/main/resdir en there you shall see folders such as:
<code>res</code> directory structure in Android Studio depicting resource qualifier bins

This directories/folders are used for different resolutions so if you need to use icon-example.png just use the different mipmap folders for different resolutions. Please check the official android guide on supporting different screen sizes.

Upvotes: 3

Related Questions