1

i've finished my layout for medium screen (5 inch i think), but i've trouble for adapting my drawable, button, and text for large and xlarge screen. How can i adapt them ? Please tell me step by step, because i feel very difficult for following many resource that i've got from many different resource and person. Thank you.

2 Answers2

1

Firstly i strongly recommended you to go through the android developer docs for How to support multiple screen in Android and Supporting Different Screen Sizes

Coming to your question, For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens. you could use different size of the layout files in res folder and also vary for drawable images based on the density..

  res/layout/my_layout.xml             // layout for normal screen size ("default")
  res/layout-small/my_layout.xml       // layout for small screen size
  res/layout-large/my_layout.xml       // layout for large screen size
  res/layout-xlarge/my_layout.xml      // layout for extra large screen size
  res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

You can use the following resource folders to create layouts for devices with larger screens : (for api level greater than 3.1 - mentioned here)

  • layout-sw320dp
  • layout-sw480dp
  • layout-sw600dp
  • layout-sw720dp

Your resource structure will be like this in your project

enter image description here

Coming to the conclusion of my answer, For supporting the multiple screen support there are different different ways is there, you need to find the better one among them.

Here is some approaches what you can try it !!

  1. Instead of different layout folders try to create a different values folders in your project and place the dimens.xml folders in it and place all your dimension values there. here is my answer
  2. Create the layout folder like mentioned in above answer and keep the respective xml files in such folders. It automatically takes from the respective folders for respective devices( ex; it will load the xml resources form layout-sw<600> folder for a 7'inch tablet) here you can get this approach
  3. Programatically differentiate your layout files for different set of devices (bit of difficult approach,but works) here is link
Community
  • 1
  • 1
King of Masses
  • 18,405
  • 4
  • 60
  • 77
0

You have to change the size of the image for different screen sizes. Android takes the image automatically depending on screen size. The size of image for

ldpi is 36px * 36px
mdpi is 48px * 48px
hdpi is 72px * 72px
xhdpi is 96px * 96px 
xxhdpi is 144px * 144px

You can get different sized images using online tools. Place proper images in different folders it will work fine.

Check this link for more information: http://developer.android.com/guide/practices/screens_support.html

keshav kowshik
  • 2,354
  • 4
  • 22
  • 45