简体   繁体   中英

How can I fix android tablet's width and height

I am making android application in tablet using fragments so that I arranged 8 buttons vertically in 10.1 tablet it is showing fine but in 7.1 tablet only 5 icons it is showing. So How can I manage height and width properly in all tablets ... please help

Remember to write different xml layouts (with same name) and place to different folders: layout-large, layout-normal, layout-small and layout-xlarge. Same is with drawables (different size images) and values (different type padding and other values). These folders are for different phone/tablet types with various resolution and screen size. If you do it, then you can easily manage layout for small device and not touch big screen devices. Device is picking xml file automatically so it's good practice to place xml files in different folders for various phones.

More information you can find in http://developer.android.com/guide/practices/screens_support.html

You can use different layout for different screen sizes. You can also add different buttons and other drawable also. Please see the link

Supporting Multiple Screens

You can write different xml layouts using different folders: For example:

res/layout
res/layout-sw600dp    //used by  7''
res/layout-sw720dp    //used by 10''

Also you can use the same layout with the same component but with different dimensions. You can use @dimen/my_dimen notation, and then put your my_dimen in different folders like:

res/values/dimens.xml
res/values-sw600dp/dimens.xml

and so on..

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

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