Android: support multiple screens

后端 未结 4 1986
無奈伤痛
無奈伤痛 2020-11-30 13:16

I am trying to make a application in Android. I want that it should be able to run on multiple phones of different screen sizes, so i studied support multiple screen on deve

4条回答
  •  情深已故
    2020-11-30 13:22

    Defining height, width and other parameters in the XML file is the better option rather than on run time. Because XML files works as metadata (data carrier) to the activity and avoids alot of confusion when onCreate mothode in called. Plus, create different folders for image quality (hdpi,xhdpi,ndpi,ldpi)

    7 inch device use mhpi 10 inch devices use hdpi and xhdpi While NEXUS tabs use hdpi and xhdpi irrespective of their size. Mobiles use ldpi and ndpi.

    Beauty lies here is that android device automatically pick-p the suitable content when found, i.e layout and image. If not found it would first search other Layout folders,e.g a layout not found in x-large folder then it will search in large,then medium, small, which one of them suits the best ,(if a layout is not found in its respective folder).

    Nexus will create alot of trouble for you. To check how your layout would look on different devices, try using the options, which tells you how it would look on that device with those height width, present in the Graphical (view of a ) layout.

提交回复
热议问题