4

As you may now know android studio 1.1 creates new image assets in the mipmap-xxx folders instead of drawable-xxx when you create assets with the IDE. The issue I'm facing here is that android takes these images as "icons" when I use them in my xml files, therefore I loose density when I try to display them at the proper size. For example with this code:

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="32dp"
        android:src="@mipmap/ic_login_logo" />

I do get the right density but the wrong size, and if I do this:

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_marginTop="32dp"
        android:src="@mipmap/ic_login_logo" />

I get the right size... but the wrong density. I'm not a UI/UX pro and I didn't face this issue before with drawables. I'm not even able to add my resources in the drawable-xxx folder from the IDE: enter image description here

Is there a workaround for this? Thank you.

E-Kami
  • 2,529
  • 5
  • 30
  • 50

1 Answers1

1

I was just searchig usage of mipmap folders. According to this answer & this Google blogspot:

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

Also this answer has a detailed explanation with references.

As i understand from reading these answers, we place icons on mipmap-xxx folders and put drawables we'll use on drawable-xxx folders just as before.

Community
  • 1
  • 1
Mel
  • 1,730
  • 17
  • 33
  • 1
    Yeah that's what I read. But my question is more: Why android studio 1.1 forces us to use mipmap everytime? I can't add an image asset in the drawable-xxx folders when I need to (when my drawable **isn't** intended to be an icon). The only way to add them in the the drawable-xxx folders is to add them as "Action bar and Tab Icons" or "Notification icons" which creates me... icons. I edited my original post to show you what I mean. – E-Kami Feb 26 '15 at 16:26
  • I'm checking. You should manually create drawable folders in same path of mipmaps, thats what i do. – Mel Feb 26 '15 at 16:36
  • I already tried but mipmap are not created with the same size as drawable were in android studio <= 1.0 resulting in a quality/density loss – E-Kami Feb 26 '15 at 17:39