How do you begin developing an Android app for multiple devices sizes/densities?

陌路散爱 提交于 2019-12-04 19:14:20

I always follow those rules:

  • set everything from supports-screens to true. Android will know that you are ready for every screen environment and you will know that it doesn't make any screen virtualization. For example: even if your device has big-size screen, your code will see it as a normal-size screen
  • don't use fixed sizes for width and height. If you must, use "dp" as a virtual pixel. use WRAP_CONTENT and FILL_PARENT. "dp" is a physical pixel on screen with 160 dpi. If your app runs on device with lower/higher density, android will recalculate this for you.
  • use "dp" as a unit for font size.
  • try to do everything relatively. U can use RelativeLayout if you want to have "something under another" etc. If you need percentages you can use LinearLayout.
  • use nine-pathes as a background.
  • make sure that you put resources into correct drawable/layout folders.

Off-course, this is not best approach for every project :) Sometimes UI designer wants some extra :]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!