0

im facing a problem with screen sizes on android. I already implemented different layouts using layout-normal, layout-large ... the problem is in layout-normal it has the coverage of 3.4 inches phones to 4.2 or more i refer to this doc

http://developer.android.com/guide/practices/screens_support.html

now im using a samsung galaxy ace with 3.5 inches everything work well, but not on my samsung s4 and the an emulator of 4.0 inches who shares the same layout. Please help me.

the probem is on layout-normal, there are severl phones who have differernt screen sizes will have diffrent output layout.

is theres a way to specify a layout for 5.1 inches, 4,0 inches ....

thank you in advance.

ralphgabb
  • 10,298
  • 3
  • 47
  • 56

2 Answers2

1

im not really sure if this is what you are looking for.. but you can check the screen size of the phone

 Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;

and set it

if(width == 480 || height == 800){
            //get resource here
 } else if (width < 480 || height < 800) {
       //get resource here

this is just an example hope it helps.

NoobMe
  • 544
  • 2
  • 6
  • 26
  • so ill layout on the code ? not creating separate folders for each? – ralphgabb Oct 23 '13 at 02:14
  • nah.. you can check this out http://stackoverflow.com/questions/17157220/easiest-way-to-know-programmatically-which-resources-folder-is-used-based-on-s the code i posted only gets the screen size, you can set where you want it to get if the width and height either small or large. – NoobMe Oct 23 '13 at 02:16
  • NoobMe is thereds a way to do it via xml ? – ralphgabb Oct 23 '13 at 02:17
  • because i was thinking about the positions of the edittext, textview, can i do that via java codes ? – ralphgabb Oct 23 '13 at 02:18
1

Your problem tells me that you are using layouts incorrectly. The layout needs to be able to fit itself inside an approximate screen size. That is what the "normal", "large", etc. screen size buckets are for. Your layout should not take up exactly "5.1" inches, because there are so many different screen sizes, that you would have to make an overwhelming number of layouts if you took this approach.

You simply need to use RelativeLayout or LinearLayout with layout_weight on the contents, and you will be able to use the same layout with multiple slightly different screen sizes.

Sky Kelsey
  • 19,192
  • 5
  • 36
  • 77