2

I am developing one application, right now i am on designing phase. i design one screen
on the 3.7WVGA(Nexus One) screen in eclipse using Linear Layout. but when i test it on 2.7
my some icon are go outside of the screen. my question is that which layout is suitable for all screen whether i design it in 3.7 inch or run it on 2.7.
Please give me a suggestion.
Thanks in Advance.
I design it in 3.7

it look like in 2.7

1st i design it in 3.7 and second in 2.7.

Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160

7 Answers7

5

Don't ever, ever, ever design a screen for Android based on an actual screen size. You will always screw yourself up because there are a hundred different screens out there. What looks good on one phone will look like crap on another. That being said, here are some tips:

  • Use RelativeLayout to lay your button contents out. Once you understand the model it's much easier than you suspect and it will make it easy to automatically scale things.

  • Only use actual pixel sizes for things that "float". You never want to specify the width of something and try to fill the width of the screen.

  • Include multiple resolutions of your images. Let the system pick the right resolution for you.

  • A table/grid layout will make things easier for you on the overall design.

  • Big panels of buttons are played out. There are other UI options at your disposal (menu buttons, swiping left and right through screens, etc.). When users see a field of buttons it looks like the app was slapped together.

Hounshell
  • 5,321
  • 4
  • 34
  • 51
  • hi @hounshell can you tell me what is the best way to check your screen design is compatible with other android device screens? is there any other way except manually check, using different device from emulator? – Rucha Bhatt Joshi Mar 26 '19 at 14:18
2

For that kind of layout use GridView if you want it scrollable, or a simple RelativeLayout if you want all the elements to scale depending on the size of the screen (use toRightOf, toLeftOf, above, below and weight to achieve that)

zrgiu
  • 6,200
  • 1
  • 33
  • 35
2

You need to consider the guide provided by android

Multiple Screen Support

What you will do is to provide all screens icon regarding different screens and you can also specify layouts for different screens, for example you want to provide drawables and layout for multiple screens, you will provide resources in that specific folder + below suffix.

Screens      for layouts          for drawables

ldpi         layout-small         drawable-ldpi
mdpi         layout               drawable-mdpi
hdpi         layout-large         drawable-hdpi
xhdpi        layout-xlarge        drawable-xhdpi

This topic will be more relavent to your need.

Ryan Alford
  • 7,514
  • 6
  • 42
  • 56
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
1

create a table layout and every row contains a vertical linear layout put all buttons inside and provides weight to each button according to need,at the last put this table layout to ScrollView that is suitable for all android devices

Brajendra Pandey
  • 2,280
  • 1
  • 16
  • 22
1

The following are the view groups in android. you can use any of these as per your requirement. But in your case You can use GridView

View Groups in android

  1. FrameLayout Layout that acts as a view frame to display a single object.
  2. Gallery A horizontal scrolling display of images, from a bound list.
  3. GridView Displays a scrolling grid of m columns and n rows.
  4. LinearLayout A layout that organizes its children into a single horizontal or vertical row. It creates a scrollbar if the length of the window exceeds the length of the screen.
  5. ListView Displays a scrolling single column list.
  6. RelativeLayout Enables you to specify the location of child objects relative to each other (child A to the left of child B) or to the parent (aligned to the top of the parent).
  7. ScrollView A vertically scrolling column of elements.
  8. Spinner Displays a single item at a time from a bound list, inside a one-row textbox. Rather like a one-row listbox that can scroll either horizontally or vertically.
  9. SurfaceView Provides direct access to a dedicated drawing surface. It can hold child views layered on top of the surface, but is intended for applications that need to draw pixels, rather than using widgets.
  10. TabHost Provides a tab selection list that monitors clicks and enables theapplication to change the screen whenever a tab is clicked.
  11. TableLayout A tabular layout with an arbitrary number of rows and columns, each cell holding the widget of your choice. The rows resize to fit the largest column. The cell borders are not visible.
  12. ViewFlipper A list that displays one item at a time, inside a one-row textbox. It can be set to swap items at timed intervals, like a slide show.
  13. ViewSwitcher Same as ViewFlipper.
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
1

I have the same problem but i found a very simple solution is use dp and sp instead px. You may read this:

What is the difference between "px", "dp", "dip" and "sp" on Android?

And you may create icons with different resolution and put it in suitble folder.

Community
  • 1
  • 1
PhatHV
  • 8,010
  • 6
  • 31
  • 40
0

I created a tool that allows you to scale/adjust your layouts for tablets and small screen devices and made a blog post about it here: http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html

Basically, defining your layouts in dp units for one size is not enough if you want your app to fit on all devices and tablets, since there's four different "density-buckets". This tool will allow your layouts to be converted into fitting these density buckets.

It also explains in further detail how to make more flexible layouts for all resolutions.

Andreas Rudolph
  • 1,226
  • 19
  • 28