0

I already read a lot of threads on stackOverflow but I didn't find what I was searching for. I already read too the official documentation but I steel have some questions.

I'm trying to insert some image in my application and I'm trying to make the layout_width to the image equals to the width screen size (in portrait).

So I make many different size for the same image and I put them in drawable-ldpi, drawable-hdpi .... But when I'm trying my image on the emulator (hdpi) it works fine, but when I'm trying this on my tablet (hdpi too) the image don't get all the width screen.

I would like to know if I have to do multiple drawable about the screen size ? and so then what about the drawable about the dpi ?

I know it's possible to put some vector image but I would like to know if I can choose the layout_width like this: android:layout_width = screen width.

and why is it so important to set the density ? A big tablet can be in mdpi et a phone on hdpi... what is so important in the density ?

LeNomade
  • 13
  • 7
  • 1
    you can set layout width to match_parent to make it always scaled to the parent width (eg. `android:layout_width="match_parent"`) – hakim Sep 09 '16 at 10:52
  • check [single image for different screen size](http://stackoverflow.com/a/37207973/2826147) – Amit Vaghela Sep 09 '16 at 10:52

2 Answers2

0

Try using android:layout_width = "match_parent" in your layout.xml this will set the width of your main layout or parent layout to stretch from one side of screen to other side of screen. setting android:layout_height = "match_parent" and android:layout_width = "match_parent" will spread the layout over whole screen (top to bottom and left to right).

AND TO SAVE TIME AND EFFORT of creating different sizes of same image and icons, you can use Android-drawable-importer plugin. With this plugin, import just 1 image and it will create different sizes (small,large,xlarge,xxlarge etc) automatically by it self.

deejay
  • 572
  • 4
  • 18
0

Thank's for answer. I'll try to use this extension and see.

Edit: It works fine but it make different image size only for the resolution (hdpi,mdpi ...) but it can't make different image size for the screen size ? Maybe I didn't see where I have to go ...

Do you know what I have to do ?

And I have a new questions: What is the vector image extension I must use in my projects ? I have .EPS and .AI but the plug in don't see theme in the search folder window. Do you know what is the step who can resolve it ?

LeNomade
  • 13
  • 7
  • this plugin will make different sizes of image and icons but you'll have to make different screen sizes layouts. To do so open xml code and preview in android studio. At the top of preview box, select different devices from drop down list(nexus5, nexus7, nexus10 etc) these options emulate screen sizes of different devices. Set your elements sizes accordingly and android will pick the best fit from drawables folder automatically. – deejay Sep 09 '16 at 18:27
  • I tryed to vote up your answer but a message show me I can't vote because I don't have 15 of reputation. Sorry – LeNomade Sep 11 '16 at 08:52