-1

I've just finished my app, so I tested it on a tablet, the quality is good, but when I try it on my smartphone (HTC One) I get a bad quality, so i wanna know why.

layour-normal:

<ImageView
    android:layout_width="210dp"
    android:layout_height="90dp"
    android:id="@+id/topLogo"
    android:layout_marginTop="5dp"
    android:src="@drawable/logo_bleu_petit"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

image-size: 250*107


enter image description here


enter image description here

benjyspider
  • 245
  • 2
  • 4
  • 16

2 Answers2

1

You should put different images in different folders of drawable. For example,put the 250*107 image in /res/drawable-mdpi, and put a 500*214 version of the same image in /res/drawable-hdpi. The app will display different images on devices with different screen size. If you only have one low-quality image in /res/drawable,when you use a device with a 1080p screen,the image might be blown up to 2x or 4x.Then it looks in bad quality.

And one more thing,try not to use a fixed width or height on an ImageView.Use scaleType so the ImageView can perform better with images of different size.

Ai Hao
  • 102
  • 5
  • Okay i'm gonna try it, but i dont understand, if normal layout = 50*50 / xlarge layout = 200*200, and drawable-mdpi = 25*25, drawable-hdpi= 75*75. I d'ont understand if xlarge choose in xhdpi and the image is little than him – benjyspider Jun 04 '15 at 08:11
  • Which drawable file is chosen is determined by the screen density.In general you don't need to set up different layout files – Ai Hao Jun 04 '15 at 08:47
  • So i have to delete my drawable-small, drawable-normal, drawable-large, drawable-xlarge files ? – benjyspider Jun 04 '15 at 08:49
  • Just use one layout file,and put different size images in /res/drawable-ldpi,/res/drawable-mdpi,/res/drawable-hdpi. Don't forget to add scaleType to the imageView. – Ai Hao Jun 04 '15 at 08:49
  • What scaleType i have to choose ? And the images dont gonna be high for smartphone ? – benjyspider Jun 04 '15 at 08:51
  • You can try CENTER_INSIDE if you want to put the image in the center of the imageView. FIT_XY will scale the image to the size of the imageView. – Ai Hao Jun 04 '15 at 08:57
  • Can you look of my edit if i have the good folders now ? Im gonna try what u said :) – benjyspider Jun 04 '15 at 09:03
  • How to do for tablet in portrait ? – benjyspider Jun 05 '15 at 07:46
0

There are diffrent drawable folder in res folder of your project. You have to provide same image file with same name but diffrent sizes in diffrent drawable folders so that when you run your app in any devices it will automatically pic the image according to its resolution.

Sahil Garg
  • 263
  • 1
  • 20
  • I dont understand so, layout normal/large/xlarge gonna choose what drawable dimensions folders ? And i put a high image resolution in all drawable dimension folders its dont work – benjyspider Jun 04 '15 at 07:51