主权项 |
1. A method for screen adaptation, comprising following steps:
A1) obtaining, by a client, UI (user interface) data packet or package from a server, parsing the UI data packet, obtaining drawing information of respective modules and drawing information of respective components, in which the modules of the UI are arranged in vertical direction, and each module contains one or a plurality of components; A2) determining, by the client, screen orientation of a device on which the client itself is, if the screen orientation is portrait screen, executing step A3; if the screen orientation is landscape screen, executing step A4; A3) setting, by the client, display width of respective modules to be screen width of the device, obtaining display width, display height and display coordinates of the respective components according to display width of the respective modules, the drawing information of the respective modules and the drawing information of the respective components; and drawing the respective components according to the display width, display height and display coordinates of the respective components and resource files required to be filled in the respective components and executing step A5; A4) setting, by the client, the display width of the respective module to be screen height of the device, obtaining display width, display height and display coordinates of the respective components according to display width of the respective modules, the drawing information of the respective modules and the drawing information of the respective components; and drawing the respective components according to the display width, display height and display coordinates of the respective components and resource files required to be filled in the respective components and executing step A5; and A5) monitoring, by the client, screen orientation of the device, going back to step A2 when detecting that screen orientation of the device changes. |