简体   繁体   中英

What layout type should i use in android in order for my app to fit all screen sizes?

I dont want objects in my xml to get cut off from being too big or have the objects too small and unseeable. Previously i used RelativeLayout but the layout didnt look the same with other screen sizes. What can i do to have all layouts fit the screen the same way? Thanks!

I suspect your problem arises from the fact that you may be using pixels for your fonts and positioning.

I would recommend using dip or dp instead of px for fonts, that should allow them to scale depending on your device (sort of like em in html). I would also use the same for positioning and sizing on elements.

The layouts in android are not so much about what layout to use for what size screens, it is more about which layout you need to use to implement your desired design. You do not have to stick to one layout for a screen / activity either, each layout can have other layouts embedded in them.

Meaning it's not uncommon to start with a LinearLayout with vertical orientation and then nest under that a LinearLayout with horizontal orientation or even a TableLayout .

Similarly you can start with a RelativeLayout and use it to position a LinearLayout somewhere on the screen.

you can use RelativeLayout , LinearLayout , FrameLayout and so on. which layout should be used to fit all screen that's a separate thing because we should use layout based on our requirement.

this site

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

is really helpful to support multiple screen. however you should always put your layout within the scroll view so if the screen is greater than layout , scrolling will not appear but in reverse case it will appear.

you should consider other paramerts also except layouts. we use layout based on our requirement.

You can use RelativeLayout so that your every View is place with some relation to other View and try to use match_parent , or you can use weight . If its necessary to fix the size of View and to make it take equal space on all screen resolutions see my answer here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM