WO2024046041A1 - Method and device for displaying user interface - Google Patents

Method and device for displaying user interface Download PDF

Info

Publication number
WO2024046041A1
WO2024046041A1 PCT/CN2023/111481 CN2023111481W WO2024046041A1 WO 2024046041 A1 WO2024046041 A1 WO 2024046041A1 CN 2023111481 W CN2023111481 W CN 2023111481W WO 2024046041 A1 WO2024046041 A1 WO 2024046041A1
Authority
WO
WIPO (PCT)
Prior art keywords
user interface
canvas
height
width
layout
Prior art date
Application number
PCT/CN2023/111481
Other languages
French (fr)
Chinese (zh)
Inventor
钱坤
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024046041A1 publication Critical patent/WO2024046041A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • the present application relates to the field of terminal technology, and in particular to a method and device for displaying a user interface (User Interface, UI).
  • UI User Interface
  • Embodiments of the present application provide a method and device for displaying a user interface, so that when the posture of the electronic device changes and switches to wide-screen display, the user interface is displayed on two pages, which increases the amount of content displayed by the electronic device and improves user experience. experience.
  • this application provides a method for displaying a user interface, which is applied to an electronic device.
  • the method can be implemented by the electronic device, including: when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval , layout the user interface of the application according to the second width and the second height, and obtain the layout view; the layout view includes the first part and the second part, the widths of the first part and the second part are both equal to the second width, and the first part is located in the second part above, the sum of the heights of the first part and the second part is less than or equal to the second height; wherein, the second width is less than the first width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first width.
  • the first height is the height of the window; by adjusting the canvas, the left half of the window displays the first part, and the right half of the window displays the second part; where the canvas is used to draw the user interface.
  • the electronic device of the present application lays out the user interface of the application program according to a second width smaller than the width of the display area and a second height higher than the height of the display area to increase the content of the layout, and by adjusting the canvas, the display screen of the electronic device
  • the user interface is displayed in two parts on the left and right (that is, the user interface is displayed on two pages), which increases the amount of content displayed on the electronic device and improves the user experience.
  • the above adjustment of the canvas includes: by panning and/or cutting the canvas, so that the first canvas is located in the left half of the window, and the second canvas is located in the right half of the window; where, the first canvas is the part of the canvas used to draw the first part, and the second canvas is the part of the canvas used to draw the second part.
  • the above-mentioned layout of the user interface of the application program according to the second width and the second height, before obtaining the layout view further includes: when the first aspect ratio of the display screen is in the threshold interval, the application program is The obtained width of the display screen is modified to the second width so that the element size in the user interface is less than or equal to the first size.
  • the first size is the element size displayed by the user interface under the second aspect ratio of the display screen, and the second The aspect ratio is smaller than the first aspect ratio.
  • the electronic device switches to wide-screen display, such as when the electronic device switches from portrait-screen display to landscape-screen display, or switches from folded state display to expanded state display
  • the size of the displayed user interface elements remains unchanged or even becomes slightly smaller
  • the user interface is displayed on two sides, which can effectively increase the amount of displayed content and improve user experience.
  • the above layout of the user interface of the application program based on the second width and the second height, and after obtaining the layout view also includes: traversing the elements in the user interface to determine whether the first element exists; The top coordinate value is less than the first height, and the bottom coordinate value is greater than the first height; when the first element exists, the offset and offset direction are determined so that the first element is displayed as a whole on the left side of the window Half or right half; provides the offset and offset direction to the application.
  • traversing to find user interface elements that may be split, and providing the offset and offset direction to the application the elements in the user interface may be displayed completely without being split even after the canvas is adjusted, which can further improve the user experience. experience.
  • the above determination of offset and offset direction includes: changing
  • the above method adjusts the canvas so that the left half of the window displays the first part and the right half of the window displays the second part.
  • the method further includes: sensing a click event of the user interface; and transferring the click event from the first part to the second part.
  • One position is mapped to a second position; where the first position is the position of the click event in the right half of the display screen, and the second position is the first position offset to the left by the second width and downward by the first height. Location. This enables the electronic device to still respond when the user interface displayed in the right half is clicked.
  • the above-mentioned layout of the user interface of the application program according to the second width and the second height, before obtaining the layout view further includes: setting a first area in the left half of the window; the first area is For displaying fixed content; providing the information of the first area to the application.
  • the above method for displaying a user interface further includes: setting a second area in the left half of the window, the second area is located below the first area, and the content displayed in the second area is consistent with the content of the window.
  • the content displayed in the right half is associated; information from the second area is provided to the application.
  • the above-mentioned layout of the user interface of the application program according to the second width and the second height to obtain a layout view also includes: laying out the user interface including the navigation bar according to the second width and the second height, Get the layout view containing the navigation bar view; the navigation bar view is located below the second part; the sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height; for example, the second height is equal to 2 ⁇ h_screen- 3 ⁇ h_b, where h_screen is the first height and h_b is the height of the navigation bar.
  • the above method adjusts the canvas so that the left half of the window displays the first part and the right half of the window displays the second part, including: adjusting the canvas so that the navigation bar view is displayed below the first and second parts in the window. Further improve user experience.
  • the above method is to adjust the canvas so that the navigation bar view is displayed below the first and second parts in the window, including: enlarging the third canvas so that the navigation bar view is displayed in the window. Below Parts One and Two. For example, double the height and width of the third canvas.
  • this application provides a method for displaying a user interface, which is applied to an electronic device and includes: receiving an offset and an offset direction; formulating layout rules according to the offset and the offset direction; and laying out the user according to the layout rules. interface, so that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact.
  • This method adapts to the processing of elements that may be split in the above method, so that the elements in the user interface are not split.
  • the present application provides a method for displaying a user interface, applied to an electronic device, including: receiving information in a first area; formulating layout rules according to the information in the first area; and laying out the user interface according to the layout rules so that The user interface is displayed on the display screen of the electronic device in two parts: left and right, and the content in the first area is fixed.
  • This method is adapted to the fixed area set in the above method and is used to improve user experience.
  • the above method for displaying a user interface further includes: receiving information of the second area; formulating layout rules according to the information of the second area; laying out the user interface according to the layout rules so that the second area is displayed
  • the content is associated with the content in the right part of the user interface to further enhance the user experience.
  • this application provides a device for displaying a user interface, which is applied to electronic equipment and includes: a layout module and a display module.
  • the layout module is used to layout the user interface of the application program according to the second width and the second height when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, and obtain a layout view; the layout view includes a first part and a third part.
  • the widths of the first part and the second part are both equal to the second width, the first part is located above the second part, and the sum of the heights of the first part and the second part is less than or equal to the second height; where the second width is less than the second part One width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first height, and the first height is the height of the window; the display module is used to adjust the canvas so that the left half of the window displays the second One part, the right half of the window shows the second part; within it, the canvas is used to draw the user interface.
  • the above display module is also used to: translate and/or cut the canvas so that the first canvas is located in the left half of the window and the second canvas is located in the right half of the window; wherein, the first canvas is located in the left half of the window.
  • the canvas is the part of the canvas used to draw the first part
  • the second canvas is the part of the canvas used to draw the second part.
  • the above device further includes: a modification module, configured to layout the user interface of the application according to the second width and the second height in the layout module, and before obtaining the layout view, modify the first width and height of the display screen.
  • a modification module configured to layout the user interface of the application according to the second width and the second height in the layout module, and before obtaining the layout view, modify the first width and height of the display screen.
  • modify the width of the display screen obtained by the application to the second width so that the size of the elements in the user interface is less than or equal to the first size, and the first size is the second width and height of the user interface on the display screen.
  • the second aspect ratio is smaller than the first aspect ratio of the displayed element dimensions.
  • the above device further includes: a traversal module, an offset determination module and a first providing module.
  • the traversal module is used to layout the user interface of the application according to the second width and the second height in the layout module, to obtain After laying out the view, traverse the elements in the user interface to determine whether there is the first element; the top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height; the offset determination module is used to determine the offset. and offset direction, so that the first element is displayed in the left half or right half of the window as a whole; the first providing module is used to provide the offset and offset direction to the application program.
  • the above offset determination module is also used to add
  • the smaller value of is used as the offset; where h is the first height; it is also used when the offset is
  • the above device also includes: a perception module and a mapping module.
  • the perception module is used to adjust the canvas in the display module so that the left half of the window displays the first part and the right half of the window displays the second part.
  • the mapping module is used to map the click event from the first position to the second position; where the first position is the position of the click event in the right half of the display screen, and the second position is the first The position is offset to the left by the second width and down by the first height.
  • the above device further includes: a first setting module and a second providing module.
  • the first setting module is configured to layout the user interface of the application according to the second width and the second height in the layout module to obtain the layout.
  • a first area is set in the left half of the window; the first area is used to display fixed content; the second providing module is used to provide information in the first area to the application.
  • the above device further includes: a second setting module and a second providing module.
  • the second setting module is used to set a second area in the left half of the window, and the second area is located below the first area. , the content displayed in the second area is associated with the content displayed in the right half of the window; the second providing module is used to provide the information of the second area to the application program.
  • the above layout module is also used to: layout the user interface including the navigation bar according to the second width and the second height, and obtain a layout view including the navigation bar view; the navigation bar view is located below the second part ; The sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height.
  • the above display module is also used to adjust the canvas so that the navigation bar view is displayed below the first part and the second part in the window.
  • the above display module is also used to: by enlarging the third canvas, the navigation bar view is displayed below the first part and the second part in the window, for example, by enlarging the height and width of the third canvas. double.
  • this application provides a device for displaying a user interface, which is applied to electronic equipment and includes: a receiving module, a rule execution module and a layout module.
  • the receiving module is used to receive an offset and an offset direction; the rule execution module Used to formulate layout rules based on offset and offset direction; the layout module is used to lay out the user interface according to the layout rules, so that the user interface is displayed in two parts on the display screen of the electronic device, and the elements in the user interface remain intact .
  • the present application provides a device for displaying a user interface, which is applied to an electronic device and includes: a first receiving module, a first rule module and a first layout module.
  • the first receiving module is used to receive a first region's information. information; the first rule module is used to formulate layout rules according to the information in the first area; the first layout module is used to layout the user interface according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts, and the The content in an area is fixed.
  • the above device further includes: a second receiving module, a second rule module and a second layout module, the second receiving module is used to receive the information of the second area; the second rule module is used to according to the first The information in the second area formulates layout rules; the second layout module is used to layout the user interface according to the layout rules, so that the content displayed in the second area is associated with the content in the right part of the user interface.
  • the present application provides an electronic device, including the device described in any one of the fourth to sixth aspects.
  • the present application provides a computer-readable storage medium in which a computer program is stored.
  • the program when run on a computer, causes the computer to execute the method of any one of the first aspect to the third aspect.
  • the present application provides a computer program, which when the computer program is executed by a computer, is used to perform the method of any one of the first to third aspects.
  • the program in the ninth aspect may be stored in whole or in part on a storage medium packaged with the processor, or in part or in whole on a memory that is not packaged with the processor.
  • Figure 1a is a view of a foldable mobile phone in an unfolded state according to an embodiment of the present application
  • Figure 1b is a view of a folding mobile phone during the folding or unfolding process provided by the embodiment of the present application
  • Figure 1c is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Figure 2 is a schematic diagram of the effect of switching an existing electronic device from a folded state to an unfolded state to display content
  • Figure 3 is a schematic diagram of the effect of switching the electronic device from a folded state to an expanded state to display content in an embodiment of the present application
  • Figure 4 is a schematic diagram of the APP user interface in the layout and drawing process in the embodiment of the present application.
  • Figure 5a is a flow chart of a method for displaying a user interface provided by an embodiment of the present application.
  • Figure 5b is a schematic layout diagram of content to be displayed in the embodiment of the present application.
  • Figure 5c is a schematic diagram of a display area on a screen used to display content to be displayed in an embodiment of the present application
  • Figure 5d is a schematic diagram of cutting the canvas in the embodiment of the present application.
  • Figure 5e is another schematic diagram of cutting the canvas in the embodiment of the present application.
  • Figure 5f is a schematic diagram of the display effect of the electronic device in the expanded state without using the technical solution of the present application in the embodiment of the present application;
  • Figure 5g is a schematic diagram of a display effect of an electronic device using a method for displaying a user interface in an expanded state in an embodiment of the present application
  • Figure 5h is a schematic diagram in which the length and width characteristics of the UI elements remain unchanged in the embodiment of the present application.
  • Figure 5i is a schematic flow chart of an electronic device switching between an unfolded state and a folded state in an embodiment of the present application
  • Figure 5j is a schematic diagram of changes in the length and width of UI elements in the embodiment of the present application.
  • Figure 6a is a schematic flowchart of mapping in a method for displaying a user interface provided by an embodiment of the present application
  • Figure 6b is a mapping schematic diagram of click events in the embodiment of the present application.
  • Figure 7a is a schematic layout diagram of the APP user interface in the embodiment of the present application.
  • Figure 7b is a schematic diagram of the APP user interface canvas shown in Figure 7a after adjustment in the embodiment of the present application;
  • Figure 7c is another display effect diagram of the display screen in the embodiment of the present application.
  • Figure 7d is a schematic flowchart of a processing flow of click events in the embodiment of the present application.
  • Figure 8a is another schematic flow chart for displaying a user interface provided by an embodiment of the present application.
  • Figure 8b is a schematic diagram of a drawing result in the embodiment of the present application.
  • Figure 8c is a schematic diagram of another layout result in the embodiment of the present application.
  • Figure 8d is another display effect diagram of the display screen in the embodiment of the present application.
  • Figure 9a is a schematic diagram of possible splitting of user interface elements in this embodiment of the present application.
  • Figure 9b is a schematic diagram of a layout result of a user interface with elements that may be split in the embodiment of the present application.
  • Figure 9c is a schematic diagram of a drawing result after the user interface is shifted upward in the embodiment of the present application.
  • Figure 9d is a schematic diagram of a drawing result after the user interface is shifted downward in the embodiment of the present application.
  • Figure 9e is a display effect diagram after shifting the user interface in the embodiment of the present application.
  • Electronic devices applicable to this application may be electronic devices with folding screens, such as mobile phones, folding tablets, folding computers, etc., or tablets, computers, etc. without folding screens.
  • the folding screen is a flexible screen.
  • Figure 1a shows a folded The view of the folded mobile phone in the unfolded state, in which the dotted line is the fold line of the folding screen.
  • Figure 1b shows a view of a folding mobile phone during the folding or unfolding process.
  • Figure 1b shows a schematic structural diagram of an electronic device.
  • an electronic device may have more or fewer components than shown in the figures, may combine two or more components, or may have a different configuration of components.
  • the various components shown in the figures may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and/or application specific integrated circuits.
  • the electronic device may include a processor 110, a memory 120, a power management module 130, an antenna 181, an antenna 182, a mobile communication module 140, a wireless communication module 150, a sensor module 160, a display screen 170, and the like.
  • the sensor module 160 may include an inertial sensor, a pressure sensor and/or a touch sensor, etc.
  • the processor 110 may include an application processor (application processor, AP), modem processor, graphics processing unit (GPU), image signal processor (image signal processor, ISP), controller, memory, video Codec, digital signal processor (DSP), baseband processor, and/or neural network processing unit (NPU), etc.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller controller
  • memory video Codec
  • DSP digital signal processor
  • NPU neural network processing unit
  • different processing units can be independent devices or integrated in one or more processors.
  • Memory 120 may be used to store computer executable program code, which may include instructions.
  • the processor 110 executes instructions stored in the memory 120 to execute various functional applications and data processing of the electronic device.
  • Memory 120 may include program storage and data storage.
  • the program storage area can store the operating system and the application program required for at least one function (such as a sound playback function, an image playback function, etc.).
  • the storage data area can store data created during the use of electronic equipment (such as audio data, phone books, etc.).
  • the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
  • the touch sensor may be combined with display screen 170 to form a touch screen (or "touch screen"). Touch sensors are used to detect touches on or near them. The touch sensor can pass the detected touch operation to the application processor to determine the touch event type. Relevant visual output can be operated through display screen 170 . In other embodiments, the touch sensor may also be disposed on the surface of the electronic device at a different location from the display screen 170 . Pressure sensors are used to sense pressure signals and convert pressure signals into electrical signals. When a touch operation is performed on the display screen 170, the electronic device detects the strength of the touch operation based on the pressure sensor, and calculates the touch position based on the detection signal of the pressure sensor.
  • Inertial sensors usually include acceleration sensors, gyroscopes and/or magnetic sensors, etc., and are used to implement attitude detection in electronic devices.
  • the electronic device can perform vertical screen display based on sensor data (in this case, the aspect ratio of the display area of the display screen can be the second aspect ratio. Since the width is smaller than the height, the second aspect ratio is less than 1 ) and horizontal screen display (at this time, the aspect ratio of the display area of the display screen can be the first aspect ratio.
  • the first aspect ratio is greater than 1), or the folding state display of the folding screen ( At this time, the aspect ratio of the display screen can be the second aspect ratio) and in the unfolded state (at this time, the aspect ratio of the display screen can be the first aspect ratio), because the width is twice the width in the folded state, and the height unchanged, therefore, the first aspect ratio is greater than the second aspect ratio when displaying in the folded state) switching.
  • the first aspect ratio is greater than the second aspect ratio when displaying in the folded state
  • the application when the electronic device is a foldable mobile phone and is displayed in an unfolded state, usually, as shown in Figure 2, the application is rearranged according to the width of the display area, so that the displayed content is enlarged and the content volume is reduced.
  • the content displayed in the display area of the folded mobile phone in the unfolded state can be shown in Figure 3.
  • the size of the content elements such as pictures and text is kept consistent with the size of the content elements displayed in the folded state.
  • the content amount in the content element size Under the same circumstances, measured by the area of the displayed content is twice the amount of displayed content in the folded state.
  • the application (Application, APP) rearranges the content to be displayed according to half of the increased width of the display area and a size greater than the height of the display area, so that the APP waits
  • the amount of displayed content has increased compared to the content displayed in the folded state.
  • the electronic device makes the width of the content to be displayed on the APP be half the width of the display area in the expanded state, and the height is greater than the height of the large screen and less than or equal to twice the height of the display area in the expanded state, and the content to be displayed is The lower half is drawn to the right half of the display area in the expanded state, thereby obtaining the display effect shown on the display screen in the expanded state in Figure 3.
  • the size of the pictures, text and other content elements displayed by the APP shall not be larger than
  • the size of the content elements displayed in the vertical screen can make the width of the page to be displayed in the APP half the width of the horizontal screen and the height twice the height of the horizontal screen, or greater than the height of the horizontal screen and less than or close to twice the height of the horizontal screen, and Draw the lower half of the page to be displayed (the height is slightly greater than the height of the upper half) to the right half of the horizontal screen.
  • the above display effects can be achieved through software installed in the electronic device.
  • Software includes the operating system of the electronic device and the APP installed in the electronic device.
  • the APP layer may include an Activity module
  • the Framework layer may include a ViewRootImpl module (that is, a class)
  • the software in the electronic device may also include a Canvas module (that is, a class).
  • the ViewRootImpl module is used to bridge the UI and the window (Window), measure and layout the view, modify the canvas size, and adjust the content drawing by calling the application programming interface (Application Programming Interface, API) provided by Canvas.
  • the Activity module is used to manage page status and page life cycle. In cooperation with the ViewRootImpl module, it layouts the user interface of the drawn content (that is, the content displayed on the display) according to the given canvas size.
  • the electronic device when the aspect ratio of the screen display area is within a certain threshold interval, can modify the screen width value W obtained by the APP to W/2, so that the APP can formulate the content element according to W/2. Size, so that the size of the content element displayed when the horizontal screen or the folded screen is in the expanded state is not larger than the size of the content element when the vertical screen or the folded screen is displayed.
  • This threshold range can cover the aspect ratio of the tablet computer when it is displayed horizontally, and the aspect ratio of the display area of the folding screen mobile phone when it is unfolded.
  • the electronic device can change the display area width value based on which the content is displayed to half of the actual display area width.
  • the display area height value is modified to be greater than the actual display area height and less than or equal to twice the actual display area height, for use when measuring and laying out the APP view, so that the APP view width obtained after measuring the layout is half the screen width and the height is greater than the screen height. And less than or equal to twice the screen height.
  • Figure 5a shows a schematic flowchart of a method for displaying a user interface.
  • the user interface display process of the APP includes:
  • Step 51 After the electronic device senses the click operation, it triggers the Activity module of the clicked APP to start, and the APP obtains the window size actually displayed by the Activity module.
  • the window size is optionally equal to the display screen size.
  • the way to obtain it is to use the context to obtain the width. For example, most APPs obtain the window size through the getResources() function and getDisplayMetrics() function.
  • Step 52 Modify the width of the display window to the second width.
  • the electronic device detects that the aspect ratio of the display screen is within the above threshold interval, it modifies the width of the display screen obtained by the APP to the second width, so that the APP sets the size of the content element according to the second width.
  • the second width is smaller than the width of the window actually used to display the APP user interface, so that the size increase ratio of the content element to be displayed is smaller than the increase ratio of the display window width.
  • the electronic device when the electronic device detects that the aspect ratio of the display screen is within the above threshold interval, if the window width value obtained by the getResources() function or the getDisplayMetrics() function is W, the electronic device will inject getResources()
  • the window width value in the function or getDisplayMetrics() function is modified to W/2, so that the APP designs or formulates the size of the content elements in the view to be displayed based on W/2 instead of formulating the size of the content elements in the view to be displayed based on W. This ensures that the final displayed view content elements will not become larger compared to portrait display or folded display.
  • the APP loads the layout file to set rules for subsequent measurements and layout.
  • the layout rules are given in the layout file.
  • the electronic device triggers the ViewRootImpl module to call the displayed total process function performTraversals to start layout and measurement.
  • Step 53 The electronic device modifies the width value W1 and the height value H1 of the display area on which the measurement layout is based to W2 and H2 respectively. Among them, W2 ⁇ W1, H1 ⁇ H2 ⁇ 2H1.
  • the width of the display window mWinFrame is modified to be half of the original value and the height is twice the original value, so that the APP can be displayed on an "ultra-tall screen" (which The aspect ratio is larger than the current maximum aspect ratio of mobile phones (18.5:9).
  • mWinFrame represents a rectangle, which represents the position and size of the window.
  • the window is an area displayed on the screen of the display screen.
  • the window size is equal to the screen size of the display screen.
  • the APP view displayed on the screen can usually be slid up and down, so the APP will make full use of the doubled screen height to lay out more content.
  • Step 54 Measure and lay out the content to be displayed according to the layout rules and W2 and H2.
  • the electronic device cooperates with the Activity module of the APP to measure and lay out the view to be displayed based on the modified width and height values of mWinFrame and the layout rules in the layout file.
  • the measurement and layout results are the layout of the content to be displayed as shown in Figure 5b.
  • the size and shape of the canvas are the same as the content to be displayed, and the position of the content to be displayed in the canvas is also determined.
  • Step 55 Draw the laid out content to be displayed in the actual display area.
  • the APP layer calls the performDraw function to start the drawing process and draw the content to be displayed shown in Figure 5b into the actual display area shown in Figure 5c.
  • the electronic device can first translate the canvas (such as Canvas) so that its top is aligned with the top of the actual display area and its left side is aligned with the left side of the actual display area, and then, the canvas is cut along the bottom edge of the actual display area, Keep the part of the canvas that is within the display area (the first canvas). After that, draw the corresponding content to be displayed in the first canvas.
  • the canvas such as Canvas
  • the electronic device translates the canvas (the canvas before cutting) so that its bottom is aligned with the bottom of the actual display area and the right side is aligned with the right side of the actual display area. After that, the canvas is cut along the top edge of the actual display area, retaining Part of the canvas (second canvas) located within the display area. After that, the corresponding content to be displayed is drawn in the second canvas. For example, when the upper half of the content to be displayed shown in Figure 5b is drawn on the left half of the actual display area shown in Figure 5c, first, as shown in Figure 5d, the electronic device translates the canvas to the actual display area shown in Figure 5c The left half of the area, with the top of the canvas aligned with the top of the actual display area.
  • the Framework layer in the electronic device can call the API interface translate() provided by Canvas to make the Canvas translate to the left half of the actual display area shown in Figure 5c, and the top of the Canvas is aligned with the top of the actual display area. Then the electronic device calls the API interface cliprect() provided by Canvas to crop the part of the Canvas within the actual display area to obtain the first canvas.
  • the APP layer calls drawRenderNode() to draw the upper half of the content to be displayed as shown in Figure 5b on the first canvas, that is, the upper half of the content to be displayed as shown in Figure 5b is on the left half of the actual display area.
  • the size of the canvas before being cut is the same as the overall size of the content to be displayed (that is, the content to be drawn in the rendering phase of the RenderNode).
  • the electronic device translates the canvas to the actual display area shown in Figure 5c The right half of the area, with the bottom of the canvas aligned with the bottom of the actual display area. Then cut the canvas along the top of the actual display area, remove the part of the canvas outside the actual display area, and obtain a second canvas. Then the lower part of the content to be displayed shown in Figure 5b is drawn in the second canvas.
  • the Framework layer in the electronic device can call the API interface translate() provided by Canvas to make the Canvas translate to the right half of the actual display area shown in Figure 5c, and the bottom of the Canvas is aligned with the bottom of the actual display area. Then the electronic device calls the API interface cliprect() provided by Canvas to crop the part of the Canvas within the actual display area to obtain the second canvas.
  • the APP layer calls drawRenderNode() to draw the lower half of the content to be displayed as shown in Figure 5b on the second canvas, that is, the lower half of the content to be displayed as shown in Figure 5b is on the right half of the actual display area. After that, the drawing results are sent to the kernel layer for rendering, and the APP user interface is finally displayed through the display screen.
  • steps 51 and 52 can be omitted.
  • the electronic device when the view changes and needs to be redrawn, such as when the user slides the APP user interface, the electronic device only needs to perform the above steps 53 to 55.
  • FIGS. 5f and 5g show schematic diagrams of the effects before and after using the technical solution provided by the above embodiment when the folding screen mobile phone is displayed in the unfolded state. It can be seen that the technical solution provided by the above embodiment can make full use of the free area in the display screen while reducing the elements, and can also ensure that the content displayed on one screen comes from one Activity and will not be cluttered. Moreover, the amount of calculation generated by the adaptation is relatively low, especially when the display screen of the electronic device is a folding screen.
  • the above embodiments are used to provide The width and height of each local UI element of the left and right half screens drawn by the technical solution are actually the same as the width and height of the UI element in the folded state.
  • the UI element has an unchanged width and height (or length and width). characteristic. In this way, when the folded state and the expanded state switch between each other, there is no need to go through the process of resizing the specified area, and there is no need to rearrange the elements inside the sub-elements. They can be drawn directly, thus saving a lot of CPU resources and accelerating folding. Improve the performance when opening and switching, and improve the efficiency when folding and unfolding.
  • the APP when the posture of the electronic device switches between the folded state and the unfolded state, the APP triggers the screen size change callback.
  • the APP directly layouts and draws the UI elements without changing the size, avoiding re-measurement of layout and drawing; UI size changes In case of change, re-measure the layout and drawing.
  • the width and height of the UI elements change, which requires resources to be redrawn in a large area, reducing the performance and efficiency between posture switches.
  • the method for displaying a user interface may further include mapping click events on the right half.
  • Figure 6a shows a schematic flowchart of mapping in a method for displaying a user interface.
  • Step 61 The electronic device senses the click event.
  • the electronic device senses the click event of the top view (DecorView) through the function superdispatchTouchEvent().
  • Step 62 After sensing the click event, the electronic device determines whether the location where the click event occurred is in the right half of the display area. For example, the electronic device can determine whether the location where the click event occurs is in the right half of the display area by determining whether the X coordinate of the click event (such as the X coordinate of the touch event of DecorView) is greater than half the width of the display area. If yes, the next step is step 63; otherwise, this process ends.
  • the X coordinate of the click event such as the X coordinate of the touch event of DecorView
  • Step 63 The electronic device maps the location where the click event occurs to the second location. For example, as shown in Figure 6b, the electronic device is offset to the left along the X coordinate from the position where the click event occurs (the length of the offset can be half the width of the display area), and is offset downward along the Y coordinate (the length of the offset can be is the height of the display area), that is, the second position is obtained.
  • the display content in the dotted frame display area shows the layout or canvas diagram before adjusting the canvas after measuring the layout.
  • the click event When a click event occurs in the right half of the display area in the above embodiment, the click event is mapped and shifted to the lower left, so that the electronic device can correctly respond to the click event.
  • the method for displaying a user interface may further include the electronic device fixing the content of the left half of the display area and setting the content of the right half to slide.
  • the electronic device can tell the APP whether the user interface is divided into left and right halves to be displayed in the display area, and the size of the fixed area (usually the left half of the display area).
  • the electronic device system may provide two interface functions, one interface function is used to inform the APP whether to use the method for displaying the user interface provided in the above embodiment, and the other interface function is used to inform the APP the size of the fixed area.
  • APP needs to be adapted.
  • the left half of the display area is fixed (not sliding) and the right half is sliding
  • the corresponding layout rules can be formulated accordingly and the measurement layout can be re-measured so that the view layout effect is as shown below
  • the fixed area is arranged in the upper half and the sliding area is arranged in the lower half.
  • the APP user interface is as shown in Figure 7b.
  • the fixed (non-sliding) area i.e. the above-mentioned first area
  • the sliding area is in the right half of the display screen.
  • the APP in the electronic device is opened, its user interface is displayed in two parts, as shown in Figure 7c.
  • the content displayed in the left half is fixed, and the content displayed in the right half can be swiped by the user.
  • the fixed area on the left provides navigation functions
  • the waterfall flow on the right provides quick browsing functions.
  • This embodiment is suitable for shopping, information, chat and other applications.
  • the home page of such applications includes a fixed navigation area and a sliding area.
  • the electronic device is a folding screen mobile phone
  • the navigation area is fixed in the left half of the folding screen and the waterfall flow area is not fixed in the right half, which can make the user experience better. Therefore, the technical solution provided by this embodiment is applied to shopping APPs that only slide part of the homepage. For example, a search box, a functional area, a fixed advertising space, etc. can be placed on the left side, and waterfall flow content can be placed on the right side. Better results.
  • the APP only needs a small amount of adaptation to achieve it.
  • Step 71 APP receives sliding information.
  • the sliding information may include the sliding position (such as coordinates).
  • the sliding information may further include the sliding direction (such as upward or downward).
  • Step 72 The APP determines whether the sliding position is in the sliding area. If so, the next step is step 73; otherwise, the process ends.
  • Step 73 Sliding processing.
  • the sliding position is in the sliding area, it means that the user interface content is about to change.
  • the electronic device starts measuring layout and drawing to update the content displayed in the sliding area in the user interface.
  • the content of the lower half of the fixed area is associated with the content displayed in the sliding area.
  • the area below the fixed area ie, the second area mentioned above
  • the method for displaying the user interface is different from the method shown in Figure 5a. As shown in Figure 8a, the difference is:
  • Step 81 During the process of measuring the layout, the electronic device halves the width value of the display area based on the measurement layout and changes the height value to It is 2 ⁇ h_screen-3 ⁇ h_b so that the navigation bar is laid out at the bottom of the display area.
  • h_screen is the height of the display area
  • h_b is the height of the navigation bar.
  • the APP can call the Framework layer interface during the measurement layout process to mark the navigation bar in the area below the content to be displayed in the layout, resulting in a layout as shown in Figure 8c.
  • Step 83 Draw the content to be displayed except for the navigation bar after the layout in the actual display area.
  • the Framework layer calls the functions translate() and clitRect(), and the control function drawRenderNode() draws the content to be displayed in the first area on the upper left canvas, and draws the content to be displayed in the second area on the upper left canvas. In the upper canvas on the right.
  • Step 84 Enlarge the navigation bar and draw it at the bottom of the display area.
  • the Framework layer calls the scaling interface of Canvas (such as the scale interface) to double the length and width of the bottom navigation bar, and controls the function drawRenderNode() to draw the navigation bar at the bottom of the display area as shown in Figure 8b. in the area.
  • the technical solution provided by this embodiment is based on dividing the display area into two left and right areas to display the APP content, and adds an area to display the navigation bar, which optimizes the visual effect of the navigation bar. As shown in Figure 8d, the navigation bar is located below the entire interface. , compared with the navigation bar shown in Figure 5g, the user experience is improved.
  • Figures 9a and 5g show schematic diagrams of possible splitting of user interface elements (UI elements) using the method provided in Figure 5a.
  • the method for displaying the UI may also include: calculating the offset of the UI element that will be split during the drawing phase (ie, the above-mentioned first element), and providing it to the APP.
  • the electronic device determines whether the UI element will be split during the drawing phase, it first traverses the top and bottom coordinate values of each UI element in the layout phase. If the top value is less than the height of the content area (i.e., the height of the display area) h, and the bottom value is greater than the content If the area height is high, it is determined that it will be split. Accordingly, the electronic device can provide that the UI element requires an offset distance of
  • the offset distance is
  • the element is offset upwards.
  • the offset distance can be greater than
  • the offset distance can be greater than
  • the electronic device can send the offset information to the APP, and the APP decides whether to offset the UI elements that will be split.
  • the offset information may be one or more of offset object (view) information, offset distance, and offset direction.
  • the layout rules will be adjusted accordingly so that UI elements will not be split during the canvas adjustment stage.
  • the APP can offset the content to be displayed as a whole, or only offset the UI elements that may be split depending on the situation (for example, when the offset is less than the distance between UI elements, only the UI elements that may be split can be offset, that is, compression and The distance between adjacent UI elements in the offset direction).
  • the drawing result obtained in the drawing stage is shown in Figure 9c.
  • the first element 910 is displayed as a whole at the bottom of the left half of the screen; the content to be displayed is After the overall downward shift is greater than
  • the first element 910 is displayed as a whole at the top of the right half of the screen.
  • Offsetting only UI elements that may be fragmented can be used to solve the fragmented picture "Huawei" in Figure 5g. It can be seen that the downward offset required for the split picture in Figure 5g is less than the distance between this picture and the picture below "Folding Phone".
  • the APP biases the "Huawei" picture downward. Just move it.
  • the split picture "Huawei" in Figure 5g is processed by the technical solution provided in this embodiment, the effect shown in Figure 9e can be obtained, further improving the user experience.
  • An embodiment of a device for displaying a user interface may include: a layout module and a display module.
  • the layout module is used to layout the user interface of the application program according to the second width and the second height when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, and obtain a layout view; the layout view includes a first part and a third part.
  • the widths of the first part and the second part are both equal to the second width, the first part is located above the second part, and the sum of the heights of the first part and the second part is less than or equal to the second height; where the second width is less than the second part One width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first height, and the first height is the height of the window; the display module is used to adjust the canvas so that the left half of the window displays the second One part, the right half of the window shows the second part; within it, the canvas is used to draw the user interface.
  • the above-mentioned device for displaying a user interface is applied in the above-mentioned electronic device (or in other words, the electronic device may include the device in this embodiment).
  • the above device may further include: a modification module, configured to layout the user interface of the application program according to the second width and the second height in the layout module and obtain the layout view in the first width of the display screen.
  • a modification module configured to layout the user interface of the application program according to the second width and the second height in the layout module and obtain the layout view in the first width of the display screen.
  • the above device may further include: a traversal module, an offset determination module and a first providing module.
  • the traversal module is used to layout the user interface of the application according to the second width and the second height in the layout module. , after obtaining the layout view, traverse the elements in the user interface to determine whether the first element exists; the top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height; the offset determination module is used to determine the offset
  • the offset and offset direction are used to make the first element appear in the left half or the right half of the window as a whole; the first providing module is used to provide the offset and offset direction to the application.
  • the above offset determination module is also used to use
  • h is the first height; it is also used to use downward as the offset direction when the offset is
  • the above device may further include: a sensing module and a mapping module.
  • the sensing module is configured to adjust the canvas in the display module so that the left half of the window displays the first part and the right half of the window displays the third part.
  • the mapping module is used to map the click event from the first position to the second position; where the first position is the position of the click event in the right half of the display screen, and the second position is The first position is offset to the left by the second width and downward by the first height.
  • the above device may further include: a first setting module and a second providing module.
  • the first setting module is used to layout the user interface of the application according to the second width and the second height in the layout module, Before obtaining the layout view, a first area is set in the left half of the window; the first area is used to display fixed content; and the second providing module is used to provide information in the first area to the application.
  • the above device may further include: a second setting module and a second providing module.
  • the second setting module is used to set a second area in the left half of the window, and the second area is located in the first area. below, the content displayed in the second area is associated with the content displayed in the right half of the window; the second providing module is used to provide information in the second area to the application.
  • the above layout module is also used to: layout the user interface including the navigation bar according to the second width and the second height, and obtain a layout view including the navigation bar view; the navigation bar view is located in the second part Below; the sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height; the above display module is also used to: adjust the canvas so that the navigation bar view is displayed in the first and second parts in the window below.
  • the above display module is also used to: by enlarging the third canvas, the navigation bar view is displayed below the first part and the second part in the window.
  • Another device embodiment for displaying a user interface may include: a receiving module, a rule execution module and a layout module.
  • the receiving module is configured to receive offsets and offset directions (such as receiving offsets and offsets sent by the Framework layer). direction); the rule execution module is used to formulate layout rules based on offset and offset direction; the layout module is used to lay out the user interface according to layout rules, So that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact.
  • the device in this embodiment can be the APP in the above method embodiment, applied to electronic equipment (or in other words, the electronic device can include the device in this embodiment).
  • the APP incorporates offset and offset direction into layout rules to prevent UI elements from being split and ensure the integrity of the final displayed UI elements.
  • Another device embodiment for displaying a user interface may include: a first receiving module, a first rule module and a first layout module.
  • the first receiving module is configured to receive information of the first area (such as receiving the first information sent by the Framework layer). information of one area); the first rule module is used to formulate layout rules according to the information of the first area; the first layout module is used to lay out the user interface according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts: left and right parts , and the content in the first area is fixed.
  • the device in this embodiment may be the APP in the above method embodiment, applied to an electronic device (or in other words, the electronic device may include the device in this embodiment).
  • the APP incorporates the information in the first area into the layout rules, thus making it possible to further realize the APP's UI with one side fixed and the other sliding.
  • the above device may also include: a second receiving module, a second rule module and a second layout module.
  • the second receiving module is used to receive information of the second area; the second rule The module is used to formulate layout rules according to the information in the second area; the second layout module is used to layout the user interface according to the layout rules to cooperate with the above operations so that the content of the second area is associated with the content of the right part of the user interface, and further Improve user experience.
  • An embodiment of the present application also provides an electronic device, including: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or multiple computer programs include instructions that, when executed by the device, cause the device to perform the method shown in the above embodiments.
  • Embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to execute the method provided by the embodiments of the present application.
  • An embodiment of the present application also provides a computer program product, which includes a computer program that, when run on a computer, causes the computer to execute the method provided by the embodiment of the present application.
  • any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of the present application is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product.
  • the computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), magnetic disks or optical disks, etc.
  • ROM read-only memory
  • RAM random access memory
  • magnetic disks or optical disks etc.

Abstract

A method and device for displaying a user interface. In the method, by means of laying out a user interface of an application program according to a second width which is less than the width of a display area and a second height which is greater than the height of the display area, an electronic device increases layout content; and by means of adjusting a canvas, the left half portion of a display screen of the electronic device displays a first portion of the user interface, and the right half portion thereof displays a second portion of the user interface.

Description

用于显示用户界面的方法及设备Methods and devices for displaying user interfaces 技术领域Technical field
本申请涉及终端技术领域,特别涉及一种用于显示用户界面(User Interface,UI)的方法及设备。The present application relates to the field of terminal technology, and in particular to a method and device for displaying a user interface (User Interface, UI).
背景技术Background technique
目前,当平板、折叠手机等大屏电子设备姿态发生变化时,如平板从竖屏显示切换为横屏显示,或折叠手机从折叠态切换为展开态显示,用于显示内容的显示区域宽度增加,而应用程序按照显示区域的宽度重新布局,放大了显示内容,导致屏幕显示的内容信息量减少。Currently, when the posture of large-screen electronic devices such as tablets and foldable mobile phones changes, such as when a tablet switches from a vertical screen display to a horizontal screen display, or a foldable mobile phone switches from a folded state to an unfolded state, the width of the display area used to display content increases. , and the application is rearranged according to the width of the display area, enlarging the display content, resulting in a reduction in the amount of content information displayed on the screen.
申请内容Application content
本申请实施例提供了一种用于显示用户界面的方法及设备,以在电子设备姿态改变切换到宽屏显示时,使得用户界面呈双页面显示,增加了电子设备显示的内容量,提升了用户体验。Embodiments of the present application provide a method and device for displaying a user interface, so that when the posture of the electronic device changes and switches to wide-screen display, the user interface is displayed on two pages, which increases the amount of content displayed by the electronic device and improves user experience. experience.
第一方面,本申请提供一种用于显示用户界面的方法,应用于电子设备,该方法可由电子设备实现,包括:当电子设备的显示屏的第一宽高比在预设的阈值区间时,根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图;布局视图包括第一部分和第二部分,第一部分和第二部分的宽度均等于第二宽度,第一部分位于第二部分的上方,第一部分和第二部分的高度之和小于或等于第二高度;其中,第二宽度小于第一宽度,第一宽度为窗口的宽度,窗口用于显示用户界面;第二高度大于第一高度,第一高度为窗口的高度;通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分;其中,画布用于绘制用户界面。本申请电子设备通过根据小于显示区域宽度的第二宽度和高于显示区域高度的第二高度布局所述应用程序的用户界面,以增加布局的内容,以及通过调整画布,使得电子设备的显示屏分左右两部分显示用户界面(即用户界面呈双页面显示),增加了电子设备显示的内容量,提升了用户体验。In a first aspect, this application provides a method for displaying a user interface, which is applied to an electronic device. The method can be implemented by the electronic device, including: when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval , layout the user interface of the application according to the second width and the second height, and obtain the layout view; the layout view includes the first part and the second part, the widths of the first part and the second part are both equal to the second width, and the first part is located in the second part above, the sum of the heights of the first part and the second part is less than or equal to the second height; wherein, the second width is less than the first width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first width. One height, the first height is the height of the window; by adjusting the canvas, the left half of the window displays the first part, and the right half of the window displays the second part; where the canvas is used to draw the user interface. The electronic device of the present application lays out the user interface of the application program according to a second width smaller than the width of the display area and a second height higher than the height of the display area to increase the content of the layout, and by adjusting the canvas, the display screen of the electronic device The user interface is displayed in two parts on the left and right (that is, the user interface is displayed on two pages), which increases the amount of content displayed on the electronic device and improves the user experience.
在一种可能的实现方式中,上述调整画布,包括:通过平移和/或裁切画布,使得第一画布位于窗口的左半部分,第二画布位于窗口的右半部分;其中,第一画布为画布上用于绘制第一部分的部分,第二画布为画布上用于绘制第二部分的部分。In a possible implementation, the above adjustment of the canvas includes: by panning and/or cutting the canvas, so that the first canvas is located in the left half of the window, and the second canvas is located in the right half of the window; where, the first canvas is the part of the canvas used to draw the first part, and the second canvas is the part of the canvas used to draw the second part.
在一种可能的实现方式中,上述根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之前,还包括:在显示屏的第一宽高比在阈值区间时,将应用程序获取的显示屏的宽度修改为第二宽度,以使用户界面中的元素尺寸小于或等于第一尺寸,第一尺寸为用户界面在显示屏的第二宽高比下显示的元素尺寸,第二宽高比小于第一宽高比。这样,电子设备切换到宽屏显示时,如电子设备从竖屏显示切换为横屏显示,或从折叠态显示切换为展开态显示时,显示的用户界面元素大小保持不变甚或略变小,且用户界面呈双面显示,能够有效增加显示的内容量,提升用户体验。In a possible implementation, the above-mentioned layout of the user interface of the application program according to the second width and the second height, before obtaining the layout view, further includes: when the first aspect ratio of the display screen is in the threshold interval, the application program is The obtained width of the display screen is modified to the second width so that the element size in the user interface is less than or equal to the first size. The first size is the element size displayed by the user interface under the second aspect ratio of the display screen, and the second The aspect ratio is smaller than the first aspect ratio. In this way, when the electronic device switches to wide-screen display, such as when the electronic device switches from portrait-screen display to landscape-screen display, or switches from folded state display to expanded state display, the size of the displayed user interface elements remains unchanged or even becomes slightly smaller, and The user interface is displayed on two sides, which can effectively increase the amount of displayed content and improve user experience.
在一种可能的实现方式中,上述根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之后,还包括:遍历用户界面中的元素,判断是否存在第一元素;第一元素的顶top坐标值小于第一高度,底bottom坐标值大于第一高度;当存在第一元素时,确定偏移量和偏移方向,以使所述第一元素整体显示在所述窗口的左半部分或右半部分;将偏移量和偏移方向提供给应用程序。通过遍历查找可能被割裂的用户界面元素,并将偏移量和偏移方向提供给应用程序,使得用户界面中的元素即使经过画布调整,也可能被完整显示而不被割裂,能够进一步提升用户体验。In a possible implementation, the above layout of the user interface of the application program based on the second width and the second height, and after obtaining the layout view, also includes: traversing the elements in the user interface to determine whether the first element exists; The top coordinate value is less than the first height, and the bottom coordinate value is greater than the first height; when the first element exists, the offset and offset direction are determined so that the first element is displayed as a whole on the left side of the window Half or right half; provides the offset and offset direction to the application. By traversing to find user interface elements that may be split, and providing the offset and offset direction to the application, the elements in the user interface may be displayed completely without being split even after the canvas is adjusted, which can further improve the user experience. experience.
在一种可能的实现方式中,上述确定偏移量和偏移方向包括:将|top-h|、|h-bottom|、或|top-h|和|h-bottom|中的较小值作为偏移量;其中,h为第一高度;当偏移 量为|top-h|时,将向下作为偏移方向;当偏移量为|h-bottom|时,将向上作为偏移方向。In a possible implementation, the above determination of offset and offset direction includes: changing |top-h|, |h-bottom|, or the smaller value of |top-h| and |h-bottom| As an offset; where h is the first height; when the offset When the offset amount is |top-h|, downward will be used as the offset direction; when the offset amount is |h-bottom|, upward will be used as the offset direction.
在一种可能的实现方式中,上述通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分之后,还包括:感知用户界面的点击事件;将点击事件从第一位置映射到第二位置;其中,第一位置为点击事件在显示屏右半部分中的位置,第二位置为第一位置向左偏移第二宽度,向下偏移第一高度后的位置。能够使得右半部显示的用户界面被点击的情况下,电子设备仍然能够响应。In a possible implementation, the above method adjusts the canvas so that the left half of the window displays the first part and the right half of the window displays the second part. The method further includes: sensing a click event of the user interface; and transferring the click event from the first part to the second part. One position is mapped to a second position; where the first position is the position of the click event in the right half of the display screen, and the second position is the first position offset to the left by the second width and downward by the first height. Location. This enables the electronic device to still respond when the user interface displayed in the right half is clicked.
在一种可能的实现方式中,上述根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之前,还包括:在窗口的左半部分设置第一区域;第一区域用于显示固定内容;将第一区域的信息提供给应用程序。使得应用程序的用户界面在双面显示时能够一半内容固定,一半内容滑动,满足更多的应用程序提供者的应用需求,以及进一步提升用户体验。In a possible implementation, the above-mentioned layout of the user interface of the application program according to the second width and the second height, before obtaining the layout view, further includes: setting a first area in the left half of the window; the first area is For displaying fixed content; providing the information of the first area to the application. This enables the user interface of an application to have half of the content fixed and half of the content sliding when displayed on both sides, meeting the application needs of more application providers and further improving the user experience.
在一种可能的实现方式中,上述用于显示用户界面的方法还包括:在窗口的左半部分设置第二区域,第二区域位于第一区域的下方,第二区域显示的内容与窗口的右半部分显示的内容关联;将第二区域的信息提供给应用程序。使得应用程序的用户界面布局能够满足更多的需求,进一步提升用户体验。In a possible implementation, the above method for displaying a user interface further includes: setting a second area in the left half of the window, the second area is located below the first area, and the content displayed in the second area is consistent with the content of the window. The content displayed in the right half is associated; information from the second area is provided to the application. This enables the user interface layout of the application to meet more needs and further enhance the user experience.
在一种可能的实现方式中,上述根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图,还包括:根据第二宽度和第二高度布局包含导航栏的用户界面,得到包含导航栏视图的布局视图;导航栏视图位于第二部分的下方;导航栏视图与第一部分和第二部分的高度之和小于或等于第二高度;例如,第二高度等于2×h_screen-3×h_b,其中,h_screen为第一高度,h_b为导航栏的高度。上述通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分,包括:通过调整画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方,进一步提升用户体验。In a possible implementation, the above-mentioned layout of the user interface of the application program according to the second width and the second height to obtain a layout view also includes: laying out the user interface including the navigation bar according to the second width and the second height, Get the layout view containing the navigation bar view; the navigation bar view is located below the second part; the sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height; for example, the second height is equal to 2×h_screen- 3×h_b, where h_screen is the first height and h_b is the height of the navigation bar. The above method adjusts the canvas so that the left half of the window displays the first part and the right half of the window displays the second part, including: adjusting the canvas so that the navigation bar view is displayed below the first and second parts in the window. Further improve user experience.
在一种可能的实现方式中,上述通过调整画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方,包括:通过放大第三画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方。例如,将第三画布的高度和宽度放大两倍。In one possible implementation, the above method is to adjust the canvas so that the navigation bar view is displayed below the first and second parts in the window, including: enlarging the third canvas so that the navigation bar view is displayed in the window. Below Parts One and Two. For example, double the height and width of the third canvas.
第二方面,本申请提供一种用于显示用户界面的方法,应用于电子设备,包括:接收偏移量和偏移方向;根据偏移量和偏移方向制定布局规则;根据布局规则布局用户界面,以使用户界面分左右两部分显示在电子设备的显示屏中,且用户界面中的元素保持完整。该方法适配上述方法中对可能发生割裂的元素进行的处理,使得用户界面中的元素不被割裂。In a second aspect, this application provides a method for displaying a user interface, which is applied to an electronic device and includes: receiving an offset and an offset direction; formulating layout rules according to the offset and the offset direction; and laying out the user according to the layout rules. interface, so that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact. This method adapts to the processing of elements that may be split in the above method, so that the elements in the user interface are not split.
第三方面,本申请提供一种用于显示用户界面的方法,应用于电子设备,包括:接收第一区域的信息;根据第一区域的信息制定布局规则;根据布局规则布局用户界面,以使用户界面分左右两部分显示在电子设备的显示屏中,且第一区域中的内容固定。该方法适配上述方法中设置固定区域,用于提升用户体验。In a third aspect, the present application provides a method for displaying a user interface, applied to an electronic device, including: receiving information in a first area; formulating layout rules according to the information in the first area; and laying out the user interface according to the layout rules so that The user interface is displayed on the display screen of the electronic device in two parts: left and right, and the content in the first area is fixed. This method is adapted to the fixed area set in the above method and is used to improve user experience.
在一种可能的实现方式中,上述用于显示用户界面的方法还包括:接收第二区域的信息;根据第二区域的信息制定布局规则;根据布局规则布局用户界面,以使第二区域显示的内容与用户界面的右部分的内容关联,进一步提升用户体验。In a possible implementation, the above method for displaying a user interface further includes: receiving information of the second area; formulating layout rules according to the information of the second area; laying out the user interface according to the layout rules so that the second area is displayed The content is associated with the content in the right part of the user interface to further enhance the user experience.
第四方面,本申请提供一种用于显示用户界面的装置,应用于电子设备,包括:布局模块和显示模块。布局模块用于当电子设备的显示屏的第一宽高比在预设的阈值区间时,根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图;布局视图包括第一部分和第二部分,第一部分和第二部分的宽度均等于第二宽度,第一部分位于第二部分的上方,第一部分和第二部分的高度之和小于或等于第二高度;其中,第二宽度小于第一宽度,第一宽度为窗口的宽度,窗口用于显示用户界面;第二高度大于第一高度,第一高度为窗口的高度;显示模块用于通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分;其中,画布用于绘制用户界面。In a fourth aspect, this application provides a device for displaying a user interface, which is applied to electronic equipment and includes: a layout module and a display module. The layout module is used to layout the user interface of the application program according to the second width and the second height when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, and obtain a layout view; the layout view includes a first part and a third part. Two parts, the widths of the first part and the second part are both equal to the second width, the first part is located above the second part, and the sum of the heights of the first part and the second part is less than or equal to the second height; where the second width is less than the second part One width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first height, and the first height is the height of the window; the display module is used to adjust the canvas so that the left half of the window displays the second One part, the right half of the window shows the second part; within it, the canvas is used to draw the user interface.
在一种可能的实现方式中,上述显示模块还用于:通过平移和/或裁切画布,使得第一画布位于窗口的左半部分,第二画布位于窗口的右半部分;其中,第一画布为画布上用于绘制第一部分的部分,第二画布为画布上用于绘制第二部分的部分。 In a possible implementation, the above display module is also used to: translate and/or cut the canvas so that the first canvas is located in the left half of the window and the second canvas is located in the right half of the window; wherein, the first canvas is located in the left half of the window. The canvas is the part of the canvas used to draw the first part, and the second canvas is the part of the canvas used to draw the second part.
在一种可能的实现方式中,上述装置还包括:修改模块,用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之前,在显示屏的第一宽高比在阈值区间时,将应用程序获取的显示屏的宽度修改为第二宽度,以使用户界面中的元素尺寸小于或等于第一尺寸,第一尺寸为用户界面在显示屏的第二宽高比下显示的元素尺寸,第二宽高比小于第一宽高比。In a possible implementation, the above device further includes: a modification module, configured to layout the user interface of the application according to the second width and the second height in the layout module, and before obtaining the layout view, modify the first width and height of the display screen. When the ratio is in the threshold interval, modify the width of the display screen obtained by the application to the second width, so that the size of the elements in the user interface is less than or equal to the first size, and the first size is the second width and height of the user interface on the display screen. The second aspect ratio is smaller than the first aspect ratio of the displayed element dimensions.
在一种可能的实现方式中,上述装置还包括:遍历模块、偏移确定模块和第一提供模块,遍历模块用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之后,遍历用户界面中的元素,判断是否存在第一元素;第一元素的顶top坐标值小于第一高度,底bottom坐标值大于第一高度;偏移确定模块用于确定偏移量和偏移方向,以使第一元素整体显示在窗口的左半部分或右半部分;第一提供模块用于将偏移量和偏移方向提供给应用程序。In a possible implementation, the above device further includes: a traversal module, an offset determination module and a first providing module. The traversal module is used to layout the user interface of the application according to the second width and the second height in the layout module, to obtain After laying out the view, traverse the elements in the user interface to determine whether there is the first element; the top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height; the offset determination module is used to determine the offset. and offset direction, so that the first element is displayed in the left half or right half of the window as a whole; the first providing module is used to provide the offset and offset direction to the application program.
在一种可能的实现方式中,上述偏移确定模块还用于当存在第一元素时,将|top-h|、|h-bottom|、或|top-h|和|h-bottom|中的较小值作为偏移量;其中,h为第一高度;还用于当偏移量为|top-h|时,将向下作为偏移方向;当偏移量为|h-bottom|时,将向上作为偏移方向。In a possible implementation, the above offset determination module is also used to add |top-h|, |h-bottom|, or |top-h| and |h-bottom| when the first element exists The smaller value of is used as the offset; where h is the first height; it is also used when the offset is |top-h|, downward is used as the offset direction; when the offset is |h-bottom| , use upward as the offset direction.
在一种可能的实现方式中,上述装置还包括:感知模块和映射模块,感知模块用于在显示模块通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分之后,感知用户界面的点击事件;映射模块用于将点击事件从第一位置映射到第二位置;其中,第一位置为点击事件在显示屏右半部分中的位置,第二位置为第一位置向左偏移第二宽度,向下偏移第一高度后的位置。In a possible implementation, the above device also includes: a perception module and a mapping module. The perception module is used to adjust the canvas in the display module so that the left half of the window displays the first part and the right half of the window displays the second part. After that, the click event of the user interface is sensed; the mapping module is used to map the click event from the first position to the second position; where the first position is the position of the click event in the right half of the display screen, and the second position is the first The position is offset to the left by the second width and down by the first height.
在一种可能的实现方式中,上述装置还包括:第一设置模块和第二提供模块,第一设置模块用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之前,在窗口的左半部分设置第一区域;第一区域用于显示固定内容;第二提供模块用于将第一区域的信息提供给应用程序。In a possible implementation, the above device further includes: a first setting module and a second providing module. The first setting module is configured to layout the user interface of the application according to the second width and the second height in the layout module to obtain the layout. Before the view, a first area is set in the left half of the window; the first area is used to display fixed content; the second providing module is used to provide information in the first area to the application.
在一种可能的实现方式中,上述装置还包括:第二设置模块和第二提供模块,第二设置模块用于在窗口的左半部分设置第二区域,第二区域位于第一区域的下方,第二区域显示的内容与窗口的右半部分显示的内容关联;第二提供模块用于将第二区域的信息提供给应用程序。In a possible implementation, the above device further includes: a second setting module and a second providing module. The second setting module is used to set a second area in the left half of the window, and the second area is located below the first area. , the content displayed in the second area is associated with the content displayed in the right half of the window; the second providing module is used to provide the information of the second area to the application program.
在一种可能的实现方式中,上述布局模块还用于:根据第二宽度和第二高度布局包含导航栏的用户界面,得到包含导航栏视图的布局视图;导航栏视图位于第二部分的下方;导航栏视图与第一部分和第二部分的高度之和小于或等于第二高度。上述显示模块还用于:通过调整画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方。In a possible implementation, the above layout module is also used to: layout the user interface including the navigation bar according to the second width and the second height, and obtain a layout view including the navigation bar view; the navigation bar view is located below the second part ;The sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height. The above display module is also used to adjust the canvas so that the navigation bar view is displayed below the first part and the second part in the window.
在一种可能的实现方式中,上述显示模块还用于:通过放大第三画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方例如将第三画布的高度和宽度放大两倍。In a possible implementation, the above display module is also used to: by enlarging the third canvas, the navigation bar view is displayed below the first part and the second part in the window, for example, by enlarging the height and width of the third canvas. double.
第五方面,本申请提供一种用于显示用户界面的装置,应用于电子设备,包括:接收模块、规则执行模块和布局模块,接收模块用于接收偏移量和偏移方向;规则执行模块用于根据偏移量和偏移方向制定布局规则;布局模块用于根据布局规则布局用户界面,以使用户界面分左右两部分显示在电子设备的显示屏中,且用户界面中的元素保持完整。In a fifth aspect, this application provides a device for displaying a user interface, which is applied to electronic equipment and includes: a receiving module, a rule execution module and a layout module. The receiving module is used to receive an offset and an offset direction; the rule execution module Used to formulate layout rules based on offset and offset direction; the layout module is used to lay out the user interface according to the layout rules, so that the user interface is displayed in two parts on the display screen of the electronic device, and the elements in the user interface remain intact .
第六方面,本申请提供一种用于显示用户界面的装置,应用于电子设备,包括:第一接收模块、第一规则模块和第一布局模块,第一接收模块用于接收第一区域的信息;第一规则模块用于根据第一区域的信息制定布局规则;第一布局模块用于根据布局规则布局用户界面,以使用户界面分左右两部分显示在电子设备的显示屏中,且第一区域中的内容固定。In a sixth aspect, the present application provides a device for displaying a user interface, which is applied to an electronic device and includes: a first receiving module, a first rule module and a first layout module. The first receiving module is used to receive a first region's information. information; the first rule module is used to formulate layout rules according to the information in the first area; the first layout module is used to layout the user interface according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts, and the The content in an area is fixed.
在一种可能的实现方式中,上述装置还包括:第二接收模块、第二规则模块和第二布局模块,第二接收模块用于接收第二区域的信息;第二规则模块用于根据第二区域的信息制定布局规则;第二布局模块用于根据布局规则布局用户界面,以使第二区域显示的内容与用户界面的右部分的内容关联。In a possible implementation, the above device further includes: a second receiving module, a second rule module and a second layout module, the second receiving module is used to receive the information of the second area; the second rule module is used to according to the first The information in the second area formulates layout rules; the second layout module is used to layout the user interface according to the layout rules, so that the content displayed in the second area is associated with the content in the right part of the user interface.
第七方面,本申请提供一种电子设备,包括上述第四方面至第六方面任一项所述的装置。In a seventh aspect, the present application provides an electronic device, including the device described in any one of the fourth to sixth aspects.
第八方面,本申请提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机程 序,当其在计算机上运行时,使得计算机执行第一方面至第三方面任一项的方法。In an eighth aspect, the present application provides a computer-readable storage medium in which a computer program is stored. The program, when run on a computer, causes the computer to execute the method of any one of the first aspect to the third aspect.
第九方面,本申请提供一种计算机程序,当计算机程序被计算机执行时,用于执行第一方面至第三方面任一项的方法。In a ninth aspect, the present application provides a computer program, which when the computer program is executed by a computer, is used to perform the method of any one of the first to third aspects.
在一种可能的设计中,第九方面中的程序可以全部或者部分存储在与处理器封装在一起的存储介质上,也可以部分或者全部存储在不与处理器封装在一起的存储器上。In one possible design, the program in the ninth aspect may be stored in whole or in part on a storage medium packaged with the processor, or in part or in whole on a memory that is not packaged with the processor.
附图说明Description of drawings
图1a为本申请实施例提供的一种折叠手机在展开态下的视图;Figure 1a is a view of a foldable mobile phone in an unfolded state according to an embodiment of the present application;
图1b为本申请实施例提供的一种折叠手机折叠过程或展开过程中的视图;Figure 1b is a view of a folding mobile phone during the folding or unfolding process provided by the embodiment of the present application;
图1c为本申请实施例提供的一种电子设备的结构示意图;Figure 1c is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
图2为现有电子设备从折叠态切换到展开态内容显示的效果示意图;Figure 2 is a schematic diagram of the effect of switching an existing electronic device from a folded state to an unfolded state to display content;
图3为本申请实施例中电子设备从折叠态切换到展开态内容显示的效果示意图;Figure 3 is a schematic diagram of the effect of switching the electronic device from a folded state to an expanded state to display content in an embodiment of the present application;
图4为本申请实施例中APP用户界面在布局及绘制过程中的示意图;Figure 4 is a schematic diagram of the APP user interface in the layout and drawing process in the embodiment of the present application;
图5a为本申请实施例提供的一种用于显示用户界面的方法流程图;Figure 5a is a flow chart of a method for displaying a user interface provided by an embodiment of the present application;
图5b为本申请实施例中待显示内容的一种布局示意图;Figure 5b is a schematic layout diagram of content to be displayed in the embodiment of the present application;
图5c为本申请实施例中用于显示待显示内容的屏幕中显示区域的示意图;Figure 5c is a schematic diagram of a display area on a screen used to display content to be displayed in an embodiment of the present application;
图5d为本申请实施例中裁切画布的一种示意图;Figure 5d is a schematic diagram of cutting the canvas in the embodiment of the present application;
图5e为本申请实施例中裁切画布的另一种示意图;Figure 5e is another schematic diagram of cutting the canvas in the embodiment of the present application;
图5f为本申请实施例中未使用本申请技术方案的电子设备在展开态下的显示效果示意图;Figure 5f is a schematic diagram of the display effect of the electronic device in the expanded state without using the technical solution of the present application in the embodiment of the present application;
图5g为本申请实施例中使用用于显示用户界面的方法的电子设备在展开态下的一种显示效果示意图;Figure 5g is a schematic diagram of a display effect of an electronic device using a method for displaying a user interface in an expanded state in an embodiment of the present application;
图5h为本申请实施例中UI元素长宽特性不变的示意图;Figure 5h is a schematic diagram in which the length and width characteristics of the UI elements remain unchanged in the embodiment of the present application;
图5i为本申请实施例中电子设备在展开态和折叠态切换时的流程示意图;Figure 5i is a schematic flow chart of an electronic device switching between an unfolded state and a folded state in an embodiment of the present application;
图5j为本申请实施例中UI元素长宽发生变化的示意图;Figure 5j is a schematic diagram of changes in the length and width of UI elements in the embodiment of the present application;
图6a为本申请实施例提供的用于显示用户界面的方法中映射的流程示意图;Figure 6a is a schematic flowchart of mapping in a method for displaying a user interface provided by an embodiment of the present application;
图6b为本申请实施例中点击事件的一种映射示意图;Figure 6b is a mapping schematic diagram of click events in the embodiment of the present application;
图7a为本申请实施例中APP用户界面的一种布局示意图;Figure 7a is a schematic layout diagram of the APP user interface in the embodiment of the present application;
图7b为本申请实施例中图7a所示APP用户界面画布调整后的一种示意图;Figure 7b is a schematic diagram of the APP user interface canvas shown in Figure 7a after adjustment in the embodiment of the present application;
图7c为本申请实施例中显示屏的另一种显示效果图;Figure 7c is another display effect diagram of the display screen in the embodiment of the present application;
图7d为本申请实施例中点击事件的一种处理流程示意图;Figure 7d is a schematic flowchart of a processing flow of click events in the embodiment of the present application;
图8a为本申请实施例提供的另一种用于显示用户界面的流程示意图;Figure 8a is another schematic flow chart for displaying a user interface provided by an embodiment of the present application;
图8b为本申请实施例中的一种绘制结果示意图;Figure 8b is a schematic diagram of a drawing result in the embodiment of the present application;
图8c为本申请实施例中的另一种布局结果示意图;Figure 8c is a schematic diagram of another layout result in the embodiment of the present application;
图8d为本申请实施例中显示屏的另一种显示效果图;Figure 8d is another display effect diagram of the display screen in the embodiment of the present application;
图9a为本申请实施例中可能出现的用户界面元素被割裂的一种示意图;Figure 9a is a schematic diagram of possible splitting of user interface elements in this embodiment of the present application;
图9b为本申请实施例中存在可能被割裂元素的用户界面的一种布局结果示意图;Figure 9b is a schematic diagram of a layout result of a user interface with elements that may be split in the embodiment of the present application;
图9c为本申请实施例中用户界面向上偏移后的一种绘制结果示意图;Figure 9c is a schematic diagram of a drawing result after the user interface is shifted upward in the embodiment of the present application;
图9d为本申请实施例中用户界面向下偏移后的一种绘制结果示意图;Figure 9d is a schematic diagram of a drawing result after the user interface is shifted downward in the embodiment of the present application;
图9e为本申请实施例中偏移用户界面后的一种显示效果图。Figure 9e is a display effect diagram after shifting the user interface in the embodiment of the present application.
具体实施方式Detailed ways
本申请的实施方式部分使用的术语仅用于对本申请的具体实施例进行解释,而非旨在限定本申请。The terms used in the embodiments of the present application are only used to explain specific embodiments of the present application and are not intended to limit the present application.
本申请适用的电子设备可以是诸如具有折叠屏的电子设备,如手机、折叠平板、折叠计算机等,还可以是不具备折叠屏的平板电脑、计算机等。其中,折叠屏是柔性屏。图1a示出了一种折 叠手机在展开态下的视图,其中,虚线为折叠屏的折线。图1b示出了一种折叠手机折叠过程或展开过程中的视图。Electronic devices applicable to this application may be electronic devices with folding screens, such as mobile phones, folding tablets, folding computers, etc., or tablets, computers, etc. without folding screens. Among them, the folding screen is a flexible screen. Figure 1a shows a folded The view of the folded mobile phone in the unfolded state, in which the dotted line is the fold line of the folding screen. Figure 1b shows a view of a folding mobile phone during the folding or unfolding process.
图1b示出了一种电子设备的结构示意图。Figure 1b shows a schematic structural diagram of an electronic device.
应该理解的是,电子设备可以具有比图中所示的更多的或者更少的部件,可以组合两个或多个的部件,或者可以具有不同的部件配置。图中所示出的各种部件可以在包括一个或多个信号处理和/或专用集成电路在内的硬件、软件、或硬件和软件的组合中实现。It will be understood that an electronic device may have more or fewer components than shown in the figures, may combine two or more components, or may have a different configuration of components. The various components shown in the figures may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and/or application specific integrated circuits.
电子设备可以包括处理器110、存储器120、电源管理模块130、天线181、天线182、移动通信模块140、无线通信模块150、传感器模块160以及显示屏170等。其中传感器模块160可以包括惯性传感器、和压力传感器和/或触摸传感器等。The electronic device may include a processor 110, a memory 120, a power management module 130, an antenna 181, an antenna 182, a mobile communication module 140, a wireless communication module 150, a sensor module 160, a display screen 170, and the like. The sensor module 160 may include an inertial sensor, a pressure sensor and/or a touch sensor, etc.
处理器110可以包括应用处理器(application processor,AP)、调制解调处理器、图形处理器(graphics processing unit,GPU)、图像信号处理器(image signal processor,ISP)、控制器、存储器、视频编解码器、数字信号处理器(digital signal processor,DSP)、基带处理器、和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include an application processor (application processor, AP), modem processor, graphics processing unit (GPU), image signal processor (image signal processor, ISP), controller, memory, video Codec, digital signal processor (DSP), baseband processor, and/or neural network processing unit (NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors.
存储器120可用于存储计算机可执行程序代码,该可执行程序代码可包括指令。处理器110通过运行存储在存储器120的指令,从而执行电子设备的各种功能应用以及数据处理。存储器120可以包括程序存储区和数据存储区。其中,程序存储区可存储操作系统,以及存储至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备使用过程中所创建的数据(比如音频数据,电话本等)等。此外,存储器120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、通用闪存存储器(universal flash storage,UFS)等。Memory 120 may be used to store computer executable program code, which may include instructions. The processor 110 executes instructions stored in the memory 120 to execute various functional applications and data processing of the electronic device. Memory 120 may include program storage and data storage. Among them, the program storage area can store the operating system and the application program required for at least one function (such as a sound playback function, an image playback function, etc.). The storage data area can store data created during the use of electronic equipment (such as audio data, phone books, etc.). In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
触摸传感器可与显示屏170组成触摸屏(或“触控屏”)。触摸传感器用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏170操作相关的视觉输出。在另一些实施例中,触摸传感器也可以设置于电子设备的表面,与显示屏170的位置不同。压力传感器用于感受压力信号,可以将压力信号转换成电信号。当有触摸操作作用于显示屏170,电子设备根据压力传感器检测该触摸操作强度,并根据压力传感器的检测信号计算触摸的位置。The touch sensor may be combined with display screen 170 to form a touch screen (or "touch screen"). Touch sensors are used to detect touches on or near them. The touch sensor can pass the detected touch operation to the application processor to determine the touch event type. Relevant visual output can be operated through display screen 170 . In other embodiments, the touch sensor may also be disposed on the surface of the electronic device at a different location from the display screen 170 . Pressure sensors are used to sense pressure signals and convert pressure signals into electrical signals. When a touch operation is performed on the display screen 170, the electronic device detects the strength of the touch operation based on the pressure sensor, and calculates the touch position based on the detection signal of the pressure sensor.
惯性传感器通常包括加速度传感器、陀螺仪和/或磁传感器等,用于在电子设备中实现姿态检测等。Inertial sensors usually include acceleration sensors, gyroscopes and/or magnetic sensors, etc., and are used to implement attitude detection in electronic devices.
本申请一些实施例中,电子设备可以根据传感器的数据进行竖屏显示(此时显示屏显示区域的宽高比可为第二宽高比,由于宽度小于高度,因此第二宽高比小于1)与横屏显示(此时显示屏显示区域的宽高比可为第一宽高比,由于宽度大于高度,因此,第一宽高比大于1)切换,或者进行折叠屏的折叠状态显示(此时显示屏的宽高比可为第二宽高比)与展开状态显示(此时显示屏的宽高比可为第一宽高比,由于宽度是折叠态时宽度的两倍,而高度不变,因此,第一宽高比大于折叠态显示时的第二宽高比)切换。电子设备在横屏显示或展开态显示时,显示的内容相较于竖屏显示或折叠态下的显示内容变多。例如,电子设备为折叠手机,处于展开态显示时,通常情况下,如图2所示,应用程序按照显示区域的宽度进行重新布局,使得显示内容被放大,内容量减少。而本申请实施例中,折叠手机展开态下显示区域显示的内容可如图3所示,保持图片文字等内容元素大小与折叠态时显示的内容元素大小一致,同时内容量(在内容元素大小相同的情况下通过显示内容的面积衡量)是折叠态下显示内容量的两倍。电子设备在显示过程中,当显示区域的宽度增加时,使应用程序(Application,APP)根据增加后的显示区域宽度的一半以及大于显示区域高度的尺寸,对待显示内容进行重新布局,使得APP待显示内容量相对于折叠态显示的内容有所增加。如图4所示,电子设备使APP待显示内容的宽度为展开态时显示区域宽度的一半,高度为大于大屏高度且小于等于展开态时显示区域高度的两倍,并将待显示内容的下半部分绘制到展开态时显示区域的右半部分,从而得到如图3中展开态下显示屏所示的显示效果。类似地,当电子设备为平板电脑时,在横屏显示时,APP显示的图片文字等内容元素的大小不大于 竖屏显示的内容元素大小,并可使APP的待显示页面宽度为横屏宽度的一半,高度为横屏高度的两倍,或者大于横屏高度且小于或接近横屏高度的两倍,并将待显示页面的下半部分(高度略大于上半部分的高度)绘制到横屏的右半部分。In some embodiments of the present application, the electronic device can perform vertical screen display based on sensor data (in this case, the aspect ratio of the display area of the display screen can be the second aspect ratio. Since the width is smaller than the height, the second aspect ratio is less than 1 ) and horizontal screen display (at this time, the aspect ratio of the display area of the display screen can be the first aspect ratio. Since the width is greater than the height, the first aspect ratio is greater than 1), or the folding state display of the folding screen ( At this time, the aspect ratio of the display screen can be the second aspect ratio) and in the unfolded state (at this time, the aspect ratio of the display screen can be the first aspect ratio), because the width is twice the width in the folded state, and the height unchanged, therefore, the first aspect ratio is greater than the second aspect ratio when displaying in the folded state) switching. When an electronic device is displayed in a horizontal screen or an expanded state, more content is displayed compared to a vertical screen display or a folded state. For example, when the electronic device is a foldable mobile phone and is displayed in an unfolded state, usually, as shown in Figure 2, the application is rearranged according to the width of the display area, so that the displayed content is enlarged and the content volume is reduced. In the embodiment of the present application, the content displayed in the display area of the folded mobile phone in the unfolded state can be shown in Figure 3. The size of the content elements such as pictures and text is kept consistent with the size of the content elements displayed in the folded state. At the same time, the content amount (in the content element size Under the same circumstances, measured by the area of the displayed content) is twice the amount of displayed content in the folded state. During the display process of the electronic device, when the width of the display area increases, the application (Application, APP) rearranges the content to be displayed according to half of the increased width of the display area and a size greater than the height of the display area, so that the APP waits The amount of displayed content has increased compared to the content displayed in the folded state. As shown in Figure 4, the electronic device makes the width of the content to be displayed on the APP be half the width of the display area in the expanded state, and the height is greater than the height of the large screen and less than or equal to twice the height of the display area in the expanded state, and the content to be displayed is The lower half is drawn to the right half of the display area in the expanded state, thereby obtaining the display effect shown on the display screen in the expanded state in Figure 3. Similarly, when the electronic device is a tablet, when displayed in landscape orientation, the size of the pictures, text and other content elements displayed by the APP shall not be larger than The size of the content elements displayed in the vertical screen can make the width of the page to be displayed in the APP half the width of the horizontal screen and the height twice the height of the horizontal screen, or greater than the height of the horizontal screen and less than or close to twice the height of the horizontal screen, and Draw the lower half of the page to be displayed (the height is slightly greater than the height of the upper half) to the right half of the horizontal screen.
上述显示效果可通过电子设备中安装的软件来实现。软件包括电子设备的操作系统以及安装在电子设备中的APP。The above display effects can be achieved through software installed in the electronic device. Software includes the operating system of the electronic device and the APP installed in the electronic device.
电子设备中的软件可以是分层架构。以安装安卓(Android)操作系统的电子设备为例,其软件最上层为APP层,与APP层相邻的下一层为应用程序框架层(即Framework层)。APP层可包括活动(Activity)模块,Framework层可包括ViewRootImpl模块(也即类),电子设备中的软件还可包括画布(Canvas)模块(也即类)。ViewRootImpl模块用于桥接UI和窗口(Window),对视图进行测量和布局,修改画布尺寸,并通过调用Canvas提供的应用程序编程接口(Application Programming Interface,API)对内容绘制进行调整。Activity模块用于管理页面状态和页面生命周期,在与ViewRootImpl模块的相互配合下,根据给定的画布大小对绘制内容(即显示屏上的显示的内容)进行用户界面布局。Software in electronic devices can be layered. Taking an electronic device installed with the Android operating system as an example, the top layer of its software is the APP layer, and the next layer adjacent to the APP layer is the application framework layer (i.e. Framework layer). The APP layer may include an Activity module, the Framework layer may include a ViewRootImpl module (that is, a class), and the software in the electronic device may also include a Canvas module (that is, a class). The ViewRootImpl module is used to bridge the UI and the window (Window), measure and layout the view, modify the canvas size, and adjust the content drawing by calling the application programming interface (Application Programming Interface, API) provided by Canvas. The Activity module is used to manage page status and page life cycle. In cooperation with the ViewRootImpl module, it layouts the user interface of the drawn content (that is, the content displayed on the display) according to the given canvas size.
在一些实施例中,电子设备可在屏幕显示区域的宽高比在某个阈值区间内时,将APP获取的屏幕宽度值W修改为W/2,使得APP根据W/2来制定内容元素的大小,从而实现在横屏或折叠屏为展开态时显示时内容元素的大小不大于竖屏或折叠态时的内容元素大小。该阈值区间可以涵盖平板电脑横屏显示时的宽高比、折叠屏手机展开态时显示区域的宽高比。In some embodiments, when the aspect ratio of the screen display area is within a certain threshold interval, the electronic device can modify the screen width value W obtained by the APP to W/2, so that the APP can formulate the content element according to W/2. Size, so that the size of the content element displayed when the horizontal screen or the folded screen is in the expanded state is not larger than the size of the content element when the vertical screen or the folded screen is displayed. This threshold range can cover the aspect ratio of the tablet computer when it is displayed horizontally, and the aspect ratio of the display area of the folding screen mobile phone when it is unfolded.
在一些实施例中,电子设备可在屏幕显示区域的宽高比在该阈值区间内时,通过将显示内容所依据的显示区域宽度值修改为实际显示区域宽度的一半,将显示内容所依据的显示区域高度值修改为大于实际显示区域高度且小于等于实际显示区域高度的两倍,供测量和布局APP视图时使用,使得测量布局后得到的APP视图宽度为屏幕宽度的一半,高度大于屏幕高度且小于等于屏幕高度的两倍。In some embodiments, when the aspect ratio of the screen display area is within the threshold interval, the electronic device can change the display area width value based on which the content is displayed to half of the actual display area width. The display area height value is modified to be greater than the actual display area height and less than or equal to twice the actual display area height, for use when measuring and laying out the APP view, so that the APP view width obtained after measuring the layout is half the screen width and the height is greater than the screen height. And less than or equal to twice the screen height.
图5a示出了一种用于显示用户界面的方法流程示意图。Figure 5a shows a schematic flowchart of a method for displaying a user interface.
当用户点击安装在电子设备上的某一APP时,该APP的用户界面显示流程包括:When a user clicks on an APP installed on an electronic device, the user interface display process of the APP includes:
步骤51:电子设备感知点击操作后,触发被点击的APP的Activity模块启动,APP获取Activity模块实际显示的窗口大小。这里,窗口大小可选地等于显示屏屏幕大小。获取的方式可以是使用上下文(context)获取宽度,例如大多数APP通过getResources()函数、getDisplayMetrics()函数获取窗口尺寸。Step 51: After the electronic device senses the click operation, it triggers the Activity module of the clicked APP to start, and the APP obtains the window size actually displayed by the Activity module. Here, the window size is optionally equal to the display screen size. The way to obtain it is to use the context to obtain the width. For example, most APPs obtain the window size through the getResources() function and getDisplayMetrics() function.
步骤52:将显示窗口的宽度修改为第二宽度。电子设备检测到显示屏的宽高比在上述阈值区间内时,将APP获取的显示屏宽度修改为第二宽度,以使得APP根据第二宽度设定内容元素的尺寸。这里第二宽度小于实际用于显示APP用户界面的窗口宽度,从而使得待显示的内容元素尺寸增大比例小于显示窗口宽度的增大比例。例如,当电子设备检测到显示屏的宽高比在上述阈值区间内时,getResources()函数或getDisplayMetrics()函数获取的窗口宽度值如为W,则电子设备通过注入的方式,将getResources()函数或getDisplayMetrics()函数中的窗口宽度值修改为W/2,从而使APP根据W/2设计或制定待显示视图中的内容元素大小,而不是根据W制定待显示视图中的内容元素大小,保证了最终显示的视图内容元素相较于竖屏显示或折叠态显示不会变大。Step 52: Modify the width of the display window to the second width. When the electronic device detects that the aspect ratio of the display screen is within the above threshold interval, it modifies the width of the display screen obtained by the APP to the second width, so that the APP sets the size of the content element according to the second width. Here, the second width is smaller than the width of the window actually used to display the APP user interface, so that the size increase ratio of the content element to be displayed is smaller than the increase ratio of the display window width. For example, when the electronic device detects that the aspect ratio of the display screen is within the above threshold interval, if the window width value obtained by the getResources() function or the getDisplayMetrics() function is W, the electronic device will inject getResources() The window width value in the function or getDisplayMetrics() function is modified to W/2, so that the APP designs or formulates the size of the content elements in the view to be displayed based on W/2 instead of formulating the size of the content elements in the view to be displayed based on W. This ensures that the final displayed view content elements will not become larger compared to portrait display or folded display.
之后,APP加载布局文件,以为后续的测量和布局设定规则。其中,布局文件中给出了布局规则。然后,电子设备触发ViewRootImpl模块调用显示的总流程函数performTraversals,以启动布局和测量。Afterwards, the APP loads the layout file to set rules for subsequent measurements and layout. Among them, the layout rules are given in the layout file. Then, the electronic device triggers the ViewRootImpl module to call the displayed total process function performTraversals to start layout and measurement.
步骤53:电子设备将测量布局所依据的显示区域的宽度值W1和高度值H1分别修改为W2和H2。其中,W2<W1,H1<H2≤2H1。Step 53: The electronic device modifies the width value W1 and the height value H1 of the display area on which the measurement layout is based to W2 and H2 respectively. Among them, W2<W1, H1<H2≤2H1.
例如,当电子设备感知到显示屏宽高比仍然在上述阈值区间时,修改显示窗口mWinFrame的宽度为原值的一半,高度为原值的两倍,使APP在一个“超高屏”(其高宽比大于目前手机的最大高宽比如18.5:9)下进行布局。mWinFrame表示一个矩形,表征的是窗口的位置和大小。窗口是显示屏的屏幕上显示的一块区域,对于全屏APP,窗口大小等于显示屏的屏幕大小。屏幕上显示的APP视图通常可上下滑动,因此APP会充分利用翻倍后的屏幕高度,布局出更多内容。 For example, when the electronic device senses that the aspect ratio of the display screen is still within the above-mentioned threshold range, the width of the display window mWinFrame is modified to be half of the original value and the height is twice the original value, so that the APP can be displayed on an "ultra-tall screen" (which The aspect ratio is larger than the current maximum aspect ratio of mobile phones (18.5:9). mWinFrame represents a rectangle, which represents the position and size of the window. The window is an area displayed on the screen of the display screen. For a full-screen APP, the window size is equal to the screen size of the display screen. The APP view displayed on the screen can usually be slid up and down, so the APP will make full use of the doubled screen height to lay out more content.
步骤54,根据布局规则以及W2和H2对待显示内容进行测量和布局。例如电子设备根据修改后的mWinFrame的宽度和高度值,以及布局文件中的布局规则,与APP的Activity模块相互配合,对待显示视图进行测量和布局。测量和布局结果为如图5b所示的待显示内容的布局。此时,画布的大小和形状与待显示内容相同,且待显示内容在画布中的位置也随之确定。Step 54: Measure and lay out the content to be displayed according to the layout rules and W2 and H2. For example, the electronic device cooperates with the Activity module of the APP to measure and lay out the view to be displayed based on the modified width and height values of mWinFrame and the layout rules in the layout file. The measurement and layout results are the layout of the content to be displayed as shown in Figure 5b. At this time, the size and shape of the canvas are the same as the content to be displayed, and the position of the content to be displayed in the canvas is also determined.
步骤55:将布局后的待显示内容绘制在实际的显示区域中。例如,APP层调用performDraw函数,以启动绘制流程,将图5b所示的待显示内容绘制到图5c所示的实际显示区域中。一些实施例中,电子设备可先平移画布(如Canvas),使其顶部与实际显示区域的顶部对齐,左边与实际显示区域的左边对齐,之后,沿着实际显示区域的底部边缘裁切画布,保留位于显示区域内的部分画布(第一画布)。之后,将相应的待显示内容绘制在第一画布中。然后,电子设备再平移画布(裁切前的画布),使其底部与实际显示区域的底部对齐,右边与实际显示区域的右边对齐,之后,沿着实际显示区域的顶部边缘裁切画布,保留位于显示区域内的部分画布(第二画布)。之后,将相应的待显示内容绘制在第二画布中。例如,将图5b所示的待显示内容的上半部分绘制在图5c所示的实际显示区域的左半部分时,首先如图5d所示,电子设备将画布平移至图5c所示实际显示区域的左半部分,且画布的顶部与实际显示区域的顶部对齐。然后沿实际显示区域的底部裁切画布,去掉画布上实际显示区域以外的部分,得到第一画布。然后将图5b所示的待显示内容的上半部分绘制在第一画布中。一些实施例中,电子设备中的Framework层可以调用Canvas提供的API接口translate()使Canvas平移至图5c所示实际显示区域的左半部分,且Canvas的顶部与实际显示区域的顶部对齐。然后电子设备调用Canvas提供的API接口cliprect(),裁切Canvas在实际显示区域内的部分,得到第一画布。APP层调用drawRenderNode(),将图5b所示待显示内容的上半部分绘制在第一画布中,即将图5b所示待显示内容的上半部分在实际显示区域的左半部分。其中,画布被裁切前大小与待显示内容(即绘制阶段待绘制的内容RenderNode)的整体大小相同。Step 55: Draw the laid out content to be displayed in the actual display area. For example, the APP layer calls the performDraw function to start the drawing process and draw the content to be displayed shown in Figure 5b into the actual display area shown in Figure 5c. In some embodiments, the electronic device can first translate the canvas (such as Canvas) so that its top is aligned with the top of the actual display area and its left side is aligned with the left side of the actual display area, and then, the canvas is cut along the bottom edge of the actual display area, Keep the part of the canvas that is within the display area (the first canvas). After that, draw the corresponding content to be displayed in the first canvas. Then, the electronic device translates the canvas (the canvas before cutting) so that its bottom is aligned with the bottom of the actual display area and the right side is aligned with the right side of the actual display area. After that, the canvas is cut along the top edge of the actual display area, retaining Part of the canvas (second canvas) located within the display area. After that, the corresponding content to be displayed is drawn in the second canvas. For example, when the upper half of the content to be displayed shown in Figure 5b is drawn on the left half of the actual display area shown in Figure 5c, first, as shown in Figure 5d, the electronic device translates the canvas to the actual display area shown in Figure 5c The left half of the area, with the top of the canvas aligned with the top of the actual display area. Then the canvas is cut along the bottom of the actual display area, and the part of the canvas outside the actual display area is removed to obtain the first canvas. Then the upper part of the content to be displayed shown in Figure 5b is drawn in the first canvas. In some embodiments, the Framework layer in the electronic device can call the API interface translate() provided by Canvas to make the Canvas translate to the left half of the actual display area shown in Figure 5c, and the top of the Canvas is aligned with the top of the actual display area. Then the electronic device calls the API interface cliprect() provided by Canvas to crop the part of the Canvas within the actual display area to obtain the first canvas. The APP layer calls drawRenderNode() to draw the upper half of the content to be displayed as shown in Figure 5b on the first canvas, that is, the upper half of the content to be displayed as shown in Figure 5b is on the left half of the actual display area. The size of the canvas before being cut is the same as the overall size of the content to be displayed (that is, the content to be drawn in the rendering phase of the RenderNode).
例如,将图5b所示的待显示内容的下半部分绘制在图5c所示的实际显示区域的右半部分时,首先如图5e所示,电子设备将画布平移至图5c所示实际显示区域的右半部分,且画布的底部与实际显示区域的底部对齐。然后沿实际显示区域的顶部裁切画布,去掉画布上实际显示区域以外的部分,得到第二画布。然后将图5b所示的待显示内容的下半部分绘制在第二画布中。一些实施例中,电子设备中的Framework层可以调用Canvas提供的API接口translate()使Canvas平移至图5c所示实际显示区域的右半部分,且Canvas的底部与实际显示区域的底部对齐。然后电子设备调用Canvas提供的API接口cliprect(),裁切Canvas在实际显示区域内的部分,得到第二画布。APP层调用drawRenderNode(),将图5b所示待显示内容的下半部分绘制在第二画布中,即将图5b所示待显示内容的下半部分在实际显示区域的右半部分。之后,将绘制结果发送到内核层进行渲染,并最终通过显示屏显示出APP用户界面。For example, when the lower half of the content to be displayed shown in Figure 5b is drawn on the right half of the actual display area shown in Figure 5c, first, as shown in Figure 5e, the electronic device translates the canvas to the actual display area shown in Figure 5c The right half of the area, with the bottom of the canvas aligned with the bottom of the actual display area. Then cut the canvas along the top of the actual display area, remove the part of the canvas outside the actual display area, and obtain a second canvas. Then the lower part of the content to be displayed shown in Figure 5b is drawn in the second canvas. In some embodiments, the Framework layer in the electronic device can call the API interface translate() provided by Canvas to make the Canvas translate to the right half of the actual display area shown in Figure 5c, and the bottom of the Canvas is aligned with the bottom of the actual display area. Then the electronic device calls the API interface cliprect() provided by Canvas to crop the part of the Canvas within the actual display area to obtain the second canvas. The APP layer calls drawRenderNode() to draw the lower half of the content to be displayed as shown in Figure 5b on the second canvas, that is, the lower half of the content to be displayed as shown in Figure 5b is on the right half of the actual display area. After that, the drawing results are sent to the kernel layer for rendering, and the APP user interface is finally displayed through the display screen.
需要说明的是,上述步骤51和步骤52可以省略。例如,一些实施例中,当view发生改变需要重绘时,如用户滑动APP用户界面时,电子设备只需执行上述步骤53至步骤55即可。It should be noted that the above steps 51 and 52 can be omitted. For example, in some embodiments, when the view changes and needs to be redrawn, such as when the user slides the APP user interface, the electronic device only needs to perform the above steps 53 to 55.
上述实施例通过修改APP获得的屏宽,修改布局所依据的显示窗口的宽度和高度,以及控制Canvas的绘制,使得APP能够更好的适配电子设备显示屏的宽高比。图5f和图5g示出了折叠屏手机在展开态显示时,使用上述实施例所提供技术方案前后的效果示意图。可以看出,采用上述实施例提供的技术方案在缩小元素的同时,充分利用了显示屏中的空余区域,还可以保证一屏展示内容出自一个Activity,不会杂乱。并且,适配所产生的计算量比较低,尤其在电子设备的显示屏为折叠屏的情况下,由于折叠态下显示屏屏幕的宽度是展开态下显示屏屏幕的一半,利用上述实施例提供的技术方案绘制的左右半屏的每个局部UI元素的宽高,实际上和折叠态时UI元素的宽高一致,如图5h所示,UI元素具有宽高(或长宽)不变的特性。这样,在折叠态和展开态相互切换时,不需要走调整指定区域的大小(resize)流程,也就不需要重新布局子元素内部的元素,可直接进行绘制,从而节省大量CPU资源,加速折叠展开切换时的性能,提升折叠、展开时的效率。如图5i所示,APP在电子设备的姿态在折叠态和展开态切换时,触发屏幕尺寸变化回调,APP在UI元素尺寸未变的情况下直接布局和绘制,避免重新测量布局和绘制;在UI尺寸变 化的情况下,重新测量布局及绘制。如图5j所示,在电子设备在展开态和折叠态之间切换时,UI元素的宽高发生了改变,需要消耗资源进行大面积重绘,降低了姿态切换之间的性能和效率。The above embodiments enable the APP to better adapt to the aspect ratio of the electronic device display screen by modifying the screen width obtained by the APP, modifying the width and height of the display window on which the layout is based, and controlling the drawing of the Canvas. Figures 5f and 5g show schematic diagrams of the effects before and after using the technical solution provided by the above embodiment when the folding screen mobile phone is displayed in the unfolded state. It can be seen that the technical solution provided by the above embodiment can make full use of the free area in the display screen while reducing the elements, and can also ensure that the content displayed on one screen comes from one Activity and will not be cluttered. Moreover, the amount of calculation generated by the adaptation is relatively low, especially when the display screen of the electronic device is a folding screen. Since the width of the display screen in the folded state is half of the display screen in the unfolded state, the above embodiments are used to provide The width and height of each local UI element of the left and right half screens drawn by the technical solution are actually the same as the width and height of the UI element in the folded state. As shown in Figure 5h, the UI element has an unchanged width and height (or length and width). characteristic. In this way, when the folded state and the expanded state switch between each other, there is no need to go through the process of resizing the specified area, and there is no need to rearrange the elements inside the sub-elements. They can be drawn directly, thus saving a lot of CPU resources and accelerating folding. Improve the performance when opening and switching, and improve the efficiency when folding and unfolding. As shown in Figure 5i, when the posture of the electronic device switches between the folded state and the unfolded state, the APP triggers the screen size change callback. The APP directly layouts and draws the UI elements without changing the size, avoiding re-measurement of layout and drawing; UI size changes In case of change, re-measure the layout and drawing. As shown in Figure 5j, when the electronic device switches between the unfolded state and the folded state, the width and height of the UI elements change, which requires resources to be redrawn in a large area, reducing the performance and efficiency between posture switches.
作为上述实施例的一种变形,用于显示用户界面的方法还可进一步包括对右半部分点击事件的映射。As a variation of the above embodiment, the method for displaying a user interface may further include mapping click events on the right half.
图6a示出了用于显示用户界面的方法中映射的流程示意图。Figure 6a shows a schematic flowchart of mapping in a method for displaying a user interface.
步骤61:电子设备感知点击事件。例如电子设备通过函数superdispatchTouchEvent()感知顶层视图(DecorView)点击事件。Step 61: The electronic device senses the click event. For example, the electronic device senses the click event of the top view (DecorView) through the function superdispatchTouchEvent().
步骤62:电子设备感知到点击事件后,判断点击事件发生的位置是否在显示区域的右半部分。例如,电子设备可以通过判断点击事件的X坐标(如DecorView的触碰事件的X坐标)是否大于显示区域宽度的一半,来判断点击事件发生的位置是否在显示区域的右半部分。如果是,则下一步执行步骤63;否则,本流程结束。Step 62: After sensing the click event, the electronic device determines whether the location where the click event occurred is in the right half of the display area. For example, the electronic device can determine whether the location where the click event occurs is in the right half of the display area by determining whether the X coordinate of the click event (such as the X coordinate of the touch event of DecorView) is greater than half the width of the display area. If yes, the next step is step 63; otherwise, this process ends.
步骤63:电子设备将点击事件发生的位置映射到第二位置。例如,如图6b所示,电子设备从点击事件发生的位置沿X坐标向左偏移(偏移的长度可为显示区域宽度一半),并沿Y坐标向下偏移(偏移的长度可为显示区域高度),即得到第二位置。图6b中,虚线框显示区域中的显示内容在测量布局后调整画布前的布局或画布示意。Step 63: The electronic device maps the location where the click event occurs to the second location. For example, as shown in Figure 6b, the electronic device is offset to the left along the X coordinate from the position where the click event occurs (the length of the offset can be half the width of the display area), and is offset downward along the Y coordinate (the length of the offset can be is the height of the display area), that is, the second position is obtained. In Figure 6b, the display content in the dotted frame display area shows the layout or canvas diagram before adjusting the canvas after measuring the layout.
当上述实施例中显示区域右半部分发生点击事件时,通过映射点击事件,将其向左下偏移,使得电子设备能够正确响应点击事件。When a click event occurs in the right half of the display area in the above embodiment, the click event is mapped and shifted to the lower left, so that the electronic device can correctly respond to the click event.
在一些实施例中,用于显示用户界面的方法还可进一步包括电子设备将显示区域左半部分内容固定,将右半部分内容设为滑动。在一些实施例中,电子设备可以告知APP:用户界面是否被分成左右两半部分显示在显示区域中,以及固定区域的大小(通常为显示区域的左半部分)。例如,电子设备系统可以提供两个接口函数,一个接口函数用于告知APP是否使用了上述实施例提供的用于显示用户界面的方法,另一个接口函数用于告知APP固定区域的大小。In some embodiments, the method for displaying a user interface may further include the electronic device fixing the content of the left half of the display area and setting the content of the right half to slide. In some embodiments, the electronic device can tell the APP whether the user interface is divided into left and right halves to be displayed in the display area, and the size of the fixed area (usually the left half of the display area). For example, the electronic device system may provide two interface functions, one interface function is used to inform the APP whether to use the method for displaying the user interface provided in the above embodiment, and the other interface function is used to inform the APP the size of the fixed area.
相应地,APP需要进行适配。当APP的供应者选择使用该功能(显示区域左半边部分固定(不可滑动),右半部分可滑动)时,可以据此制定相应的布局规则,并重新进行测量布局,使得视图布局效果如图7a所示,固定区域布局在上半部分,滑动区布局在下半部分。之后经过处理画布及绘制,使得APP用户界面如图7b所示,固定(不可滑动)区域(即上述第一区域)在显示屏的左半部分,滑动区在显示屏的右半部分。这样,电子设备中APP被打开后,其用户界面如图7c所示分左右两部分显示,左半部分显示的内容固定,右半部分显示的内容用户可滑动浏览。左侧固定区提供导航功能,右侧瀑布流提供快速浏览功能。本实施例适用于购物类、信息类、聊天类等应用,该类应用的首页包括固定导航区和可滑动区域。当电子设备为折叠屏手机时,折叠屏左半部分固定导航区,右半部分不固定瀑布流区域,可以使得用户体验更好。因此,本实施例提供的技术方案应用于在主页仅一部分滑动的购物类APP,例如左侧可放置搜索框,功能区,固定广告位等,右侧可放置瀑布流内容。效果更佳。并且,APP仅需要做少量适配便可实现。Accordingly, APP needs to be adapted. When the supplier of the APP chooses to use this function (the left half of the display area is fixed (not sliding) and the right half is sliding), the corresponding layout rules can be formulated accordingly and the measurement layout can be re-measured so that the view layout effect is as shown below As shown in 7a, the fixed area is arranged in the upper half and the sliding area is arranged in the lower half. After processing the canvas and drawing, the APP user interface is as shown in Figure 7b. The fixed (non-sliding) area (i.e. the above-mentioned first area) is in the left half of the display screen, and the sliding area is in the right half of the display screen. In this way, after the APP in the electronic device is opened, its user interface is displayed in two parts, as shown in Figure 7c. The content displayed in the left half is fixed, and the content displayed in the right half can be swiped by the user. The fixed area on the left provides navigation functions, and the waterfall flow on the right provides quick browsing functions. This embodiment is suitable for shopping, information, chat and other applications. The home page of such applications includes a fixed navigation area and a sliding area. When the electronic device is a folding screen mobile phone, the navigation area is fixed in the left half of the folding screen and the waterfall flow area is not fixed in the right half, which can make the user experience better. Therefore, the technical solution provided by this embodiment is applied to shopping APPs that only slide part of the homepage. For example, a search box, a functional area, a fixed advertising space, etc. can be placed on the left side, and waterfall flow content can be placed on the right side. Better results. Moreover, the APP only needs a small amount of adaptation to achieve it.
当用户滑动APP用户界面时,APP执行如图7d所示的流程:When the user slides the APP user interface, the APP executes the process shown in Figure 7d:
步骤71:APP接收滑动信息。一些实施例中,该滑动信息可包括滑动位置(如坐标),另一些实施例中,该滑动信息还可进一步包括滑动方向(如向上或向下)等。Step 71: APP receives sliding information. In some embodiments, the sliding information may include the sliding position (such as coordinates). In other embodiments, the sliding information may further include the sliding direction (such as upward or downward).
步骤72:APP判断滑动位置是否处于滑动区,若是,则下一步执行步骤73;否则,结束本流程。Step 72: The APP determines whether the sliding position is in the sliding area. If so, the next step is step 73; otherwise, the process ends.
步骤73:滑动处理。当滑动位置处于滑动区时,意味着用户界面内容即将发生变动,此时电子设备启动测量布局以及绘制,以更新用户界面中滑动区所显示的内容。Step 73: Sliding processing. When the sliding position is in the sliding area, it means that the user interface content is about to change. At this time, the electronic device starts measuring layout and drawing to update the content displayed in the sliding area in the user interface.
作为上述实施例的另一种变形,固定区域的下半部分内容与滑动区域显示的内容相关联。例如,当滑动区出现汽车图片时,则固定区域的下方区域(即上述第二区域)展示更多品牌的汽车信息,或展示与滑动区汽车图片相关联的更多详细信息,如图片中的汽车规格参数、用户评价等。As another variation of the above embodiment, the content of the lower half of the fixed area is associated with the content displayed in the sliding area. For example, when a car picture appears in the sliding area, the area below the fixed area (ie, the second area mentioned above) displays more brand car information, or displays more detailed information associated with the car picture in the sliding area, such as in the picture Car specifications, user reviews, etc.
针对如图5g所示底部导航栏显示在右半屏的下方的这种情况,在一些实施例中,用于显示用户界面的方法与图5a所示的方法有所区别。如图8a所示,该区别在于:For the situation where the bottom navigation bar is displayed below the right half of the screen as shown in Figure 5g, in some embodiments, the method for displaying the user interface is different from the method shown in Figure 5a. As shown in Figure 8a, the difference is:
步骤81:在测量布局过程中,电子设备将测量布局所依据的显示区域的宽度值折半,高度值改 为2×h_screen-3×h_b,以使得导航栏布局在显示区域的底部。其中,h_screen为显示区域高度,h_b为导航栏高度。Step 81: During the process of measuring the layout, the electronic device halves the width value of the display area based on the measurement layout and changes the height value to It is 2×h_screen-3×h_b so that the navigation bar is laid out at the bottom of the display area. Among them, h_screen is the height of the display area, and h_b is the height of the navigation bar.
为了使导航栏如图8b所示那样呈现在显示区域的底部,需要在测量布局后得到如图8c所示的布局,将导航栏布局在待显示内容区域的下方。因此,APP可在测量布局过程中调用Framework层接口,以在布局的待显示内容的下方区域标记导航栏,得到如图8c所示的布局。In order to make the navigation bar appear at the bottom of the display area as shown in Figure 8b, it is necessary to obtain the layout as shown in Figure 8c after measuring the layout, and layout the navigation bar below the content area to be displayed. Therefore, the APP can call the Framework layer interface during the measurement layout process to mark the navigation bar in the area below the content to be displayed in the layout, resulting in a layout as shown in Figure 8c.
图8b中,显示区域的高度为h_screen,导航栏的高度为2×h_b,因此第一区域和第二区域的高度均为h_screen-2×h_b,二者高度之和为2×(h_screen-2×h_b),再加上底部导航栏的高度h_b,由此得到需要将测量布局所依据的显示区域的高度修改为2×(h_screen-2×h_b)+h_b=2×h_screen-3×h_b,从而得到图8c所示的布局。In Figure 8b, the height of the display area is h_screen, and the height of the navigation bar is 2×h_b. Therefore, the heights of the first area and the second area are both h_screen-2×h_b, and the sum of their heights is 2×(h_screen-2 ×h_b), plus the height h_b of the bottom navigation bar, it is obtained that the height of the display area based on the measurement layout needs to be modified to 2×(h_screen-2×h_b)+h_b=2×h_screen-3×h_b, This results in the layout shown in Figure 8c.
步骤83:将布局后除导航栏以为的待显示内容绘制在实际的显示区域中。例如,Framework层调用函数translate()和clitRect(),控制函数drawRenderNode()将高度为第一区域中的待显示内容绘制在左边靠上的画布中,把第二区域中的待显示内容绘制在右边靠上的画布中。Step 83: Draw the content to be displayed except for the navigation bar after the layout in the actual display area. For example, the Framework layer calls the functions translate() and clitRect(), and the control function drawRenderNode() draws the content to be displayed in the first area on the upper left canvas, and draws the content to be displayed in the second area on the upper left canvas. In the upper canvas on the right.
步骤84:放大导航栏并绘制在显示区域的底部。例如,Framework层调用Canvas的缩放接口(如scale接口),将底部导航栏的长宽均放大两倍,并控制函数drawRenderNode()将导航栏绘制在如图8b所示的显示区域底部的第三区域中。Step 84: Enlarge the navigation bar and draw it at the bottom of the display area. For example, the Framework layer calls the scaling interface of Canvas (such as the scale interface) to double the length and width of the bottom navigation bar, and controls the function drawRenderNode() to draw the navigation bar at the bottom of the display area as shown in Figure 8b. in the area.
本实施例提供的技术方案在显示区域分左右两块区域显示APP内容的基础上,增加一块区域显示导航栏,优化了导航栏的视觉效果,如图8d所示,导航栏位于整个界面的下方,相较于图5g中显示的导航栏,提升了用户体验。The technical solution provided by this embodiment is based on dividing the display area into two left and right areas to display the APP content, and adds an area to display the navigation bar, which optimizes the visual effect of the navigation bar. As shown in Figure 8d, the navigation bar is located below the entire interface. , compared with the navigation bar shown in Figure 5g, the user experience is improved.
图9a和图5g示出了采用图5a提供的方法可能出现的用户界面元素(UI元素)被割裂的示意图。为避免一个UI元素被分割为两部分(如图9a所示,第一元素910在绘制阶段被割裂为第一部分911和第二部分912)显示,作为上述实施例的另一种变形,在电子设备处理画布之前,用于显示UI的方法还可包括:对于在绘制阶段会被割裂开的UI元素(即上述第一元素),计算偏移量,并提供给APP。Figures 9a and 5g show schematic diagrams of possible splitting of user interface elements (UI elements) using the method provided in Figure 5a. In order to avoid a UI element being split into two parts (as shown in Figure 9a, the first element 910 is split into a first part 911 and a second part 912 during the drawing stage), as another variation of the above embodiment, in electronic Before the device processes the canvas, the method for displaying the UI may also include: calculating the offset of the UI element that will be split during the drawing phase (ie, the above-mentioned first element), and providing it to the APP.
如图9b所示,由于安卓系统中布局的UI元素是矩形,因而可以用坐标(如左(left)、顶(top)、右(right)、底(bottom))描述UI元素的位置。As shown in Figure 9b, since the UI elements laid out in the Android system are rectangular, coordinates (such as left, top, right, and bottom) can be used to describe the position of the UI element.
电子设备判断UI元素是否会在绘制阶段被割裂时,首先在布局阶段遍历每个UI元素的top和bottom坐标值,如果top值小于内容区高度(即显示区域高度)h,且bottom值大于内容区高度,则判定其会被割裂开。据此,电子设备可以给出UI元素需要偏移距离为|h-top|或|bottom-h|,或者为|h-top|和|bottom-h|中的较小值。其中,将偏移距离设置为|h-top|和|bottom-h|中的较小值更佳。如果偏移距离为|h-top|,则需要将可能被割裂的UI元素及其下方的元素整体向下偏移;如果偏移距离为|bottom-h|,则需要将可能被割裂的UI元素向上偏移。在一些实施例中,当UI元素需要向下偏移时,偏移距离可以大于|h-top|,只要满足偏移后,切割位置位于图9b所示第四区域即可。在一些实施例中,当UI元素需要向上偏移时,偏移距离可以大于|bottom-h|,只要满足偏移后,切割位置位于图9b所示第五区域即可。When the electronic device determines whether the UI element will be split during the drawing phase, it first traverses the top and bottom coordinate values of each UI element in the layout phase. If the top value is less than the height of the content area (i.e., the height of the display area) h, and the bottom value is greater than the content If the area height is high, it is determined that it will be split. Accordingly, the electronic device can provide that the UI element requires an offset distance of |h-top| or |bottom-h|, or the smaller value of |h-top| and |bottom-h|. Among them, it is better to set the offset distance to the smaller value of |h-top| and |bottom-h|. If the offset distance is |h-top|, you need to offset the UI elements that may be split and the elements below them downward as a whole; if the offset distance is |bottom-h|, you need to move the UI elements that may be split The element is offset upwards. In some embodiments, when the UI element needs to be offset downward, the offset distance can be greater than |h-top|, as long as the cutting position is located in the fourth area shown in Figure 9b after the offset is satisfied. In some embodiments, when the UI element needs to be offset upward, the offset distance can be greater than |bottom-h|, as long as the cutting position is located in the fifth area shown in Figure 9b after the offset is met.
之后,电子设备可将偏移信息发送给APP,由APP决策是否偏移会被割裂的UI元素。其中,偏移信息可以是偏移对象(视图)信息、偏移距离和偏移方向中的一项或多项。当APP决定偏移UI元素,以避免UI元素割裂时,将据此调整布局规则,从而使得UI元素在画布调整阶段不会被割裂。APP可以整体偏移待显示内容,也可视情况仅偏移可能被割裂的UI元素(如偏移量小于UI元素之间的距离时,可仅偏移可能被割裂的UI元素,即压缩与偏移方向上相邻的UI元素之间的距离)。例如,将待显示内容整体向上偏移|bottom-h|后,在绘制阶段得到的绘制结果如图9c所示,第一元素910整体显示在屏幕的左半部分底部的位置;将待显示内容整体向下偏移大于|h-top|的距离后,在绘制阶段得到的绘制结果图9d所示,第一元素910整体显示在屏幕的右半部分顶部的位置。仅偏移可能被割裂的UI元素可用于解决图5g中被割裂的图片“华为”。可以看出,图5g中被割裂的图片所需的向下偏移量小于该图片与下方图片“折叠手机”之间的距离,因此,测量布局过程中,APP将“华为”图片向下偏移即可。图5g中被割裂的图片“华为”经过本实施例提供的技术方案处理后,可得到如图9e所示的效果,进一步提升了用户体验。 Afterwards, the electronic device can send the offset information to the APP, and the APP decides whether to offset the UI elements that will be split. The offset information may be one or more of offset object (view) information, offset distance, and offset direction. When the APP decides to offset UI elements to avoid splitting of UI elements, the layout rules will be adjusted accordingly so that UI elements will not be split during the canvas adjustment stage. The APP can offset the content to be displayed as a whole, or only offset the UI elements that may be split depending on the situation (for example, when the offset is less than the distance between UI elements, only the UI elements that may be split can be offset, that is, compression and The distance between adjacent UI elements in the offset direction). For example, after the entire content to be displayed is shifted upward |bottom-h|, the drawing result obtained in the drawing stage is shown in Figure 9c. The first element 910 is displayed as a whole at the bottom of the left half of the screen; the content to be displayed is After the overall downward shift is greater than |h-top|, the drawing result obtained in the drawing stage is shown in Figure 9d. The first element 910 is displayed as a whole at the top of the right half of the screen. Offsetting only UI elements that may be fragmented can be used to solve the fragmented picture "Huawei" in Figure 5g. It can be seen that the downward offset required for the split picture in Figure 5g is less than the distance between this picture and the picture below "Folding Phone". Therefore, during the measurement layout process, the APP biases the "Huawei" picture downward. Just move it. After the split picture "Huawei" in Figure 5g is processed by the technical solution provided in this embodiment, the effect shown in Figure 9e can be obtained, further improving the user experience.
本申请实施例提供的一种用于显示用户界面的装置实施例可包括:布局模块和显示模块。布局模块用于当电子设备的显示屏的第一宽高比在预设的阈值区间时,根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图;布局视图包括第一部分和第二部分,第一部分和第二部分的宽度均等于第二宽度,第一部分位于第二部分的上方,第一部分和第二部分的高度之和小于或等于第二高度;其中,第二宽度小于第一宽度,第一宽度为窗口的宽度,窗口用于显示用户界面;第二高度大于第一高度,第一高度为窗口的高度;显示模块用于通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分;其中,画布用于绘制用户界面。An embodiment of a device for displaying a user interface provided by an embodiment of the present application may include: a layout module and a display module. The layout module is used to layout the user interface of the application program according to the second width and the second height when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, and obtain a layout view; the layout view includes a first part and a third part. Two parts, the widths of the first part and the second part are both equal to the second width, the first part is located above the second part, and the sum of the heights of the first part and the second part is less than or equal to the second height; where the second width is less than the second part One width, the first width is the width of the window, and the window is used to display the user interface; the second height is greater than the first height, and the first height is the height of the window; the display module is used to adjust the canvas so that the left half of the window displays the second One part, the right half of the window shows the second part; within it, the canvas is used to draw the user interface.
上述用于显示用户界面的装置应用在上述电子设备中(或者说,电子设备可包括该实施例中的装置)。The above-mentioned device for displaying a user interface is applied in the above-mentioned electronic device (or in other words, the electronic device may include the device in this embodiment).
作为上述实施例的一种变形,上述装置还可包括:修改模块,用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之前,在显示屏的第一宽高比在阈值区间时,将应用程序获取的显示屏的宽度修改为第二宽度,以使用户界面中的元素尺寸小于或等于第一尺寸,第一尺寸为用户界面在显示屏的第二宽高比下显示的元素尺寸,第二宽高比小于第一宽高比。As a variation of the above embodiment, the above device may further include: a modification module, configured to layout the user interface of the application program according to the second width and the second height in the layout module and obtain the layout view in the first width of the display screen. When the height ratio is in the threshold interval, modify the width of the display screen obtained by the application to the second width, so that the size of the elements in the user interface is less than or equal to the first size, and the first size is the second width of the user interface on the display screen. The size of the element displayed in an aspect ratio where the second aspect ratio is smaller than the first aspect ratio.
作为上述实施例的另一种变形,上述装置还可包括:遍历模块、偏移确定模块和第一提供模块,遍历模块用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之后,遍历用户界面中的元素,判断是否存在第一元素;第一元素的顶top坐标值小于第一高度,底bottom坐标值大于第一高度;偏移确定模块用于确定偏移量和偏移方向,以使第一元素整体显示在窗口的左半部分或右半部分;第一提供模块用于将偏移量和偏移方向提供给应用程序。As another variation of the above embodiment, the above device may further include: a traversal module, an offset determination module and a first providing module. The traversal module is used to layout the user interface of the application according to the second width and the second height in the layout module. , after obtaining the layout view, traverse the elements in the user interface to determine whether the first element exists; the top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height; the offset determination module is used to determine the offset The offset and offset direction are used to make the first element appear in the left half or the right half of the window as a whole; the first providing module is used to provide the offset and offset direction to the application.
上述偏移确定模块还用于当存在第一元素时,将|top-h|、|h-bottom|、或|top-h|和|h-bottom|中的较小值作为偏移量;其中,h为第一高度;还用于当偏移量为|top-h|时,将向下作为偏移方向;当偏移量为|h-bottom|时,将向上作为偏移方向。The above offset determination module is also used to use |top-h|, |h-bottom|, or the smaller value of |top-h| and |h-bottom| as the offset when the first element exists; Among them, h is the first height; it is also used to use downward as the offset direction when the offset is |top-h|; when the offset is |h-bottom|, use upward as the offset direction.
作为上述实施例的另一种变形,上述装置还可包括:感知模块和映射模块,感知模块用于在显示模块通过调整画布,使得窗口的左半部分显示第一部分,窗口的右半部分显示第二部分之后,感知用户界面的点击事件;映射模块用于将点击事件从第一位置映射到第二位置;其中,第一位置为点击事件在显示屏右半部分中的位置,第二位置为第一位置向左偏移第二宽度,向下偏移第一高度后的位置。As another variation of the above embodiment, the above device may further include: a sensing module and a mapping module. The sensing module is configured to adjust the canvas in the display module so that the left half of the window displays the first part and the right half of the window displays the third part. After the second part, the click event of the user interface is sensed; the mapping module is used to map the click event from the first position to the second position; where the first position is the position of the click event in the right half of the display screen, and the second position is The first position is offset to the left by the second width and downward by the first height.
作为上述实施例的另一种变形,上述装置还可包括:第一设置模块和第二提供模块,第一设置模块用于在布局模块根据第二宽度和第二高度布局应用程序的用户界面,得到布局视图之前,在窗口的左半部分设置第一区域;第一区域用于显示固定内容;第二提供模块用于将第一区域的信息提供给应用程序。As another variation of the above embodiment, the above device may further include: a first setting module and a second providing module. The first setting module is used to layout the user interface of the application according to the second width and the second height in the layout module, Before obtaining the layout view, a first area is set in the left half of the window; the first area is used to display fixed content; and the second providing module is used to provide information in the first area to the application.
作为上述实施例的另一种变形,上述装置还可包括:第二设置模块和第二提供模块,第二设置模块用于在窗口的左半部分设置第二区域,第二区域位于第一区域的下方,第二区域显示的内容与窗口的右半部分显示的内容关联;第二提供模块用于将第二区域的信息提供给应用程序。As another variation of the above embodiment, the above device may further include: a second setting module and a second providing module. The second setting module is used to set a second area in the left half of the window, and the second area is located in the first area. below, the content displayed in the second area is associated with the content displayed in the right half of the window; the second providing module is used to provide information in the second area to the application.
作为上述实施例的另一种变形,上述布局模块还用于:根据第二宽度和第二高度布局包含导航栏的用户界面,得到包含导航栏视图的布局视图;导航栏视图位于第二部分的下方;导航栏视图与第一部分和第二部分的高度之和小于或等于第二高度;上述显示模块还用于:通过调整画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方。As another variation of the above embodiment, the above layout module is also used to: layout the user interface including the navigation bar according to the second width and the second height, and obtain a layout view including the navigation bar view; the navigation bar view is located in the second part Below; the sum of the heights of the navigation bar view and the first and second parts is less than or equal to the second height; the above display module is also used to: adjust the canvas so that the navigation bar view is displayed in the first and second parts in the window below.
作为上述实施例的另一种变形,上述显示模块还用于:通过放大第三画布,使得导航栏视图在窗口中,显示在第一部分和第二部分的下方。As another variation of the above embodiment, the above display module is also used to: by enlarging the third canvas, the navigation bar view is displayed below the first part and the second part in the window.
另一种用于显示用户界面的装置实施例可包括:接收模块、规则执行模块和布局模块,接收模块用于接收偏移量和偏移方向(如接收Framework层发送的偏移量和偏移方向);规则执行模块用于根据偏移量和偏移方向制定布局规则;布局模块用于根据布局规则布局用户界面, 以使用户界面分左右两部分显示在电子设备的显示屏中,且用户界面中的元素保持完整。本实施例中的装置可为上述方法实施例中的APP,应用于电子设备(或者说,电子设备可包括该实施例中的装置),相对于上述为避免UI元素被割裂所做的处理,APP将偏移量和偏移方向纳入布局规则,从而避免UI元素被割裂,保证最终显示的UI元素的完整。Another device embodiment for displaying a user interface may include: a receiving module, a rule execution module and a layout module. The receiving module is configured to receive offsets and offset directions (such as receiving offsets and offsets sent by the Framework layer). direction); the rule execution module is used to formulate layout rules based on offset and offset direction; the layout module is used to lay out the user interface according to layout rules, So that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact. The device in this embodiment can be the APP in the above method embodiment, applied to electronic equipment (or in other words, the electronic device can include the device in this embodiment). Compared with the above processing to prevent UI elements from being split, The APP incorporates offset and offset direction into layout rules to prevent UI elements from being split and ensure the integrity of the final displayed UI elements.
另一种用于显示用户界面的装置实施例可包括:第一接收模块、第一规则模块和第一布局模块,第一接收模块用于接收第一区域的信息(如接收Framework层发送的第一区域的信息);第一规则模块用于根据第一区域的信息制定布局规则;第一布局模块用于根据布局规则布局用户界面,以使用户界面分左右两部分显示在电子设备的显示屏中,且第一区域中的内容固定。本实施例中的装置可为上述方法实施例中的APP,应用于电子设备(或者说,电子设备可包括该实施例中的装置)。相对于上述为实现显示屏中UI双面显示时一面固定另一面滑动所做的处理,APP将第一区域的信息纳入布局规则,从而为进一步实现APP的UI一面固定一面滑动提供了可能。Another device embodiment for displaying a user interface may include: a first receiving module, a first rule module and a first layout module. The first receiving module is configured to receive information of the first area (such as receiving the first information sent by the Framework layer). information of one area); the first rule module is used to formulate layout rules according to the information of the first area; the first layout module is used to lay out the user interface according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts: left and right parts , and the content in the first area is fixed. The device in this embodiment may be the APP in the above method embodiment, applied to an electronic device (or in other words, the electronic device may include the device in this embodiment). Compared with the above-mentioned processing to achieve double-sided display of the UI on the display screen with one side fixed and the other sliding, the APP incorporates the information in the first area into the layout rules, thus making it possible to further realize the APP's UI with one side fixed and the other sliding.
作为上述装置(APP)实施例的一种变形,上述装置还可包括:第二接收模块、第二规则模块和第二布局模块,第二接收模块用于接收第二区域的信息;第二规则模块用于根据第二区域的信息制定布局规则;第二布局模块用于根据布局规则布局用户界面,以与上述操作相配合,使第二区域的内容与用户界面的右部分的内容关联,进一步提升用户体验。As a modification of the above device (APP) embodiment, the above device may also include: a second receiving module, a second rule module and a second layout module. The second receiving module is used to receive information of the second area; the second rule The module is used to formulate layout rules according to the information in the second area; the second layout module is used to layout the user interface according to the layout rules to cooperate with the above operations so that the content of the second area is associated with the content of the right part of the user interface, and further Improve user experience.
可以理解的是,上述实施例中的部分或全部步骤或操作仅是示例,本申请实施例还可以执行其它操作或者各种操作的变形。此外,各个步骤可以按照上述实施例呈现的不同的顺序来执行,并且有可能并非要执行上述实施例中的全部操作。It can be understood that some or all of the steps or operations in the above embodiments are only examples, and the embodiments of the present application can also perform other operations or variations of various operations. In addition, various steps may be performed in a different order than presented in the above-described embodiments, and it is possible that not all operations in the above-described embodiments are performed.
本申请实施例还提供一种电子设备,包括:一个或多个处理器;存储器;以及一个或多个计算机程序,其中所述一个或多个计算机程序被存储在所述存储器中,所述一个或多个计算机程序包括指令,当所述指令被所述设备执行时,使得所述设备执行上述实施例所示的方法。An embodiment of the present application also provides an electronic device, including: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or multiple computer programs include instructions that, when executed by the device, cause the device to perform the method shown in the above embodiments.
本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行本申请实施例提供的方法。Embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to execute the method provided by the embodiments of the present application.
本申请实施例还提供一种计算机程序产品,该计算机程序产品包括计算机程序,当其在计算机上运行时,使得计算机执行本申请实施例提供的方法。An embodiment of the present application also provides a computer program product, which includes a computer program that, when run on a computer, causes the computer to execute the method provided by the embodiment of the present application.
本申请实施例中,“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A、同时存在A和B、单独存在B的情况。其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a和b,a和c,b和c或a和b和c,其中a,b,c可以是单个,也可以是多个。In the embodiment of this application, "and/or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean that A exists alone, A and B exist simultaneously, and B exists alone. Condition. Where A and B can be singular or plural. The character "/" generally indicates that the related objects are in an "or" relationship. "At least one of the following" and similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can mean: a, b, c, a and b, a and c, b and c or a and b and c, where a, b, c can be single, also Can be multiple.
本领域普通技术人员可以意识到,本文中公开的实施例中描述的各单元及算法步骤,能够以电子硬件、计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that each unit and algorithm step described in the embodiments disclosed herein can be implemented by a combination of electronic hardware, computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be described again here.
在本申请所提供的几个实施例中,任一功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory;以下简称:ROM)、随机存取存储器(Random Access Memory;以下简称:RAM)、磁碟或者光盘等各种可以存储程序代码的介质。 In the several embodiments provided in this application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), magnetic disks or optical disks, etc. A medium on which program code can be stored.
以上所述,仅为本申请的具体实施方式,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。本申请的保护范围应以所述权利要求的保护范围为准。 The above are only specific embodiments of the present application. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, and they should be covered by the protection scope of the present application. The protection scope of this application shall be subject to the protection scope of the claims.

Claims (28)

  1. 一种用于显示用户界面的方法,应用于电子设备,其特征在于,包括:A method for displaying a user interface, applied to electronic devices, characterized by including:
    当所述电子设备的显示屏的第一宽高比在预设的阈值区间时,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图;所述布局视图包括第一部分和第二部分,所述第一部分和第二部分的宽度均等于所述第二宽度,所述第一部分位于所述第二部分的上方,所述第一部分和第二部分的高度之和小于或等于所述第二高度;其中,所述第二宽度小于第一宽度,所述第一宽度为窗口的宽度,所述窗口用于显示所述用户界面;所述第二高度大于第一高度,所述第一高度为所述窗口的高度;When the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, the user interface of the application program is laid out according to the second width and the second height to obtain a layout view; the layout view includes a first part and a second part, the width of the first part and the second part is equal to the second width, the first part is located above the second part, and the sum of the heights of the first part and the second part is less than or Equal to the second height; wherein the second width is smaller than the first width, the first width is the width of a window, and the window is used to display the user interface; the second height is greater than the first height, The first height is the height of the window;
    通过调整画布,使得所述窗口的左半部分显示所述第一部分,所述窗口的右半部分显示所述第二部分;其中,所述画布用于绘制所述用户界面。By adjusting the canvas, the left half of the window displays the first part, and the right half of the window displays the second part; wherein the canvas is used to draw the user interface.
  2. 根据权利要求1所述的方法,其特征在于,调整画布,包括:The method according to claim 1, characterized in that adjusting the canvas includes:
    通过平移和/或裁切所述画布,使得第一画布位于所述窗口的左半部分,第二画布位于所述窗口的右半部分;其中,所述第一画布为所述画布上用于绘制所述第一部分的部分,所述第二画布为所述画布上用于绘制所述第二部分的部分。By translating and/or cutting the canvas, the first canvas is located in the left half of the window, and the second canvas is located in the right half of the window; wherein, the first canvas is used on the canvas The part for drawing the first part, and the second canvas is the part of the canvas used for drawing the second part.
  3. 根据权利要求1或2所述的方法,其特征在于,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之前,还包括:The method according to claim 1 or 2, characterized in that, before laying out the user interface of the application program according to the second width and the second height, and obtaining the layout view, it further includes:
    在所述显示屏的第一宽高比在所述阈值区间时,将所述应用程序获取的所述显示屏的宽度修改为所述第二宽度,以使所述用户界面中的元素尺寸小于或等于第一尺寸,所述第一尺寸为所述用户界面在所述显示屏的第二宽高比下显示的元素尺寸,所述第二宽高比小于所述第一宽高比。When the first aspect ratio of the display screen is in the threshold interval, the width of the display screen obtained by the application program is modified to the second width, so that the element size in the user interface is smaller than Or equal to a first size, which is an element size of the user interface displayed in a second aspect ratio of the display screen, and the second aspect ratio is smaller than the first aspect ratio.
  4. 根据权利要求1至3任一项所述的方法,其特征在于,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之后,还包括:The method according to any one of claims 1 to 3, characterized in that, after laying out the user interface of the application program according to the second width and the second height, and obtaining the layout view, it further includes:
    遍历所述用户界面中的元素,判断是否存在第一元素;所述第一元素的顶top坐标值小于所述第一高度,底bottom坐标值大于所述第一高度;Traverse the elements in the user interface and determine whether there is a first element; the top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height;
    当存在所述第一元素时,确定偏移量和偏移方向,以使所述第一元素整体显示在所述窗口的左半部分或右半部分;When the first element exists, determine the offset amount and offset direction so that the first element is displayed as a whole in the left half or the right half of the window;
    将所述偏移量和偏移方向提供给所述应用程序。Provide the offset and offset direction to the application.
  5. 根据权利要求4所述的方法,其特征在于,确定偏移量和偏移方向包括:The method of claim 4, wherein determining the offset amount and offset direction includes:
    将|top-h|、|h-bottom|、或|top-h|和|h-bottom|中的较小值作为所述偏移量;其中,h为所述第一高度;Use |top-h|, |h-bottom|, or the smaller value of |top-h| and |h-bottom| as the offset; where h is the first height;
    当所述偏移量为|top-h|时,将向下作为偏移方向;当所述偏移量为|h-bottom|时,将向上作为偏移方向。When the offset is |top-h|, downward is used as the offset direction; when the offset is |h-bottom|, upward is used as the offset direction.
  6. 根据权利要求1至5任一项所述的方法,其特征在于,通过调整画布,使得所述窗口的左半部分显示所述第一部分,所述窗口的右半部分显示所述第二部分之后,还包括:The method according to any one of claims 1 to 5, characterized in that by adjusting the canvas, the left half of the window displays the first part, and the right half of the window displays the second part. ,Also includes:
    感知用户界面的点击事件;Sense click events on the user interface;
    将所述点击事件从第一位置映射到第二位置;其中,所述第一位置为所述点击事件在所述显示屏右半部分中的位置,所述第二位置为所述第一位置向左偏移所述第二宽度,向下偏移所述第一高度后的位置。The click event is mapped from a first position to a second position; wherein the first position is the position of the click event in the right half of the display screen, and the second position is the first position Offset the second width to the left and offset the first height downward.
  7. 根据权利要求1至6任一项所述的方法,其特征在于,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之前,还包括:The method according to any one of claims 1 to 6, characterized in that, before laying out the user interface of the application program according to the second width and the second height, and obtaining the layout view, it further includes:
    在所述窗口的左半部分设置第一区域;所述第一区域用于显示固定内容;A first area is set in the left half of the window; the first area is used to display fixed content;
    将所述第一区域的信息提供给所述应用程序。Information of the first area is provided to the application.
  8. 根据权利要求7所述的方法,其特征在于,还包括:在所述窗口的左半部分设置第二区域,所述第二区域位于所述第一区域的下方,所述第二区域显示的内容与所述窗口的右半部分显示的内容关联; The method according to claim 7, further comprising: setting a second area in the left half of the window, the second area being located below the first area, and the second area displaying Content associated with content displayed in the right half of said window;
    将所述第二区域的信息提供给所述应用程序。Information of the second area is provided to the application.
  9. 根据权利要求1至8任一项所述的方法,其特征在于,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图,还包括:The method according to any one of claims 1 to 8, characterized in that, laying out the user interface of the application program according to the second width and the second height to obtain a layout view, further comprising:
    根据第二宽度和第二高度布局包含导航栏的所述用户界面,得到包含导航栏视图的布局视图;所述导航栏视图位于所述第二部分的下方;所述导航栏视图与所述第一部分和所述第二部分的高度之和小于或等于所述第二高度;The user interface including the navigation bar is laid out according to the second width and the second height to obtain a layout view including the navigation bar view; the navigation bar view is located below the second part; the navigation bar view is connected to the third part. The sum of the heights of one part and the second part is less than or equal to the second height;
    通过调整画布,使得所述窗口的左半部分显示所述第一部分,所述窗口的右半部分显示所述第二部分,包括:通过调整画布,使得所述导航栏视图在所述窗口中,显示在所述第一部分和第二部分的下方。By adjusting the canvas, the left half of the window displays the first part, and the right half of the window displays the second part, including: adjusting the canvas so that the navigation bar view is in the window, Shown below the first and second parts.
  10. 根据权利要求9所述的方法,其特征在于,通过调整画布,使得所述导航栏视图在所述窗口中,显示在所述第一部分和第二部分的下方,包括:The method according to claim 9, characterized in that by adjusting the canvas so that the navigation bar view is displayed below the first part and the second part in the window, the method includes:
    通过放大第三画布,使得所述导航栏视图在所述窗口中,显示在所述第一部分和第二部分的下方;其中,所述第三画布为所述画布上用于绘制所述导航栏视图的部分。By enlarging the third canvas, the navigation bar view is displayed below the first part and the second part in the window; wherein the third canvas is used to draw the navigation bar on the canvas. part of the view.
  11. 一种用于显示用户界面的方法,应用于电子设备,其特征在于,包括:A method for displaying a user interface, applied to electronic devices, characterized by including:
    接收偏移量和偏移方向;Receive offset and offset direction;
    根据所述偏移量和偏移方向制定布局规则;Develop layout rules based on the offset and offset direction;
    根据所述布局规则布局用户界面,以使所述用户界面分左右两部分显示在所述电子设备的显示屏中,且所述用户界面中的元素保持完整。The user interface is laid out according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact.
  12. 一种用于显示用户界面的方法,应用于电子设备,其特征在于,包括:A method for displaying a user interface, applied to electronic devices, characterized by including:
    接收第一区域的信息;Receive information from the first area;
    根据所述第一区域的信息制定布局规则;Develop layout rules based on the information in the first area;
    根据所述布局规则布局用户界面,以使所述用户界面分左右两部分显示在所述电子设备的显示屏中,且所述第一区域中的内容固定。The user interface is laid out according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the content in the first area is fixed.
  13. 根据权利要求12所述的方法,其特征在于,还包括:The method of claim 12, further comprising:
    接收第二区域的信息;Receive information from the second area;
    根据所述第二区域的信息制定布局规则;Develop layout rules based on the information in the second area;
    根据所述布局规则布局用户界面,以使所述第二区域显示的内容与所述用户界面的右部分的内容关联。The user interface is laid out according to the layout rules so that the content displayed in the second area is associated with the content of the right part of the user interface.
  14. 一种用于显示用户界面的装置,应用于电子设备,其特征在于,包括:A device for displaying a user interface, applied to electronic equipment, characterized by including:
    布局模块,用于当所述电子设备的显示屏的第一宽高比在预设的阈值区间时,根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图;所述布局视图包括第一部分和第二部分,所述第一部分和第二部分的宽度均等于所述第二宽度,所述第一部分位于所述第二部分的上方,所述第一部分和第二部分的高度之和小于或等于所述第二高度;其中,所述第二宽度小于第一宽度,所述第一宽度为窗口的宽度,所述窗口用于显示所述用户界面;所述第二高度大于第一高度,所述第一高度为所述窗口的高度;a layout module, configured to lay out the user interface of the application program according to the second width and the second height when the first aspect ratio of the display screen of the electronic device is within a preset threshold interval, and obtain a layout view; The layout view includes a first part and a second part, the widths of the first part and the second part are both equal to the second width, the first part is located above the second part, and the first part and the second part are The sum of heights is less than or equal to the second height; wherein the second width is less than the first width, the first width is the width of a window, and the window is used to display the user interface; the second height Greater than a first height, which is the height of the window;
    显示模块,用于通过调整画布,使得所述窗口的左半部分显示所述第一部分,所述窗口的右半部分显示所述第二部分;其中,所述画布用于绘制所述用户界面。A display module is configured to adjust the canvas so that the left half of the window displays the first part and the right half of the window displays the second part; wherein the canvas is used to draw the user interface.
  15. 根据权利要求14所述的装置,其特征在于,所述显示模块还用于:通过平移和/或裁切所述画布,使得第一画布位于所述窗口的左半部分,第二画布位于所述窗口的右半部分;其中,所述第一画布为所述画布上用于绘制所述第一部分的部分,所述第二画布为所述画布上用于绘制所述第二部分的部分。The device according to claim 14, wherein the display module is further configured to: translate and/or cut the canvas so that the first canvas is located in the left half of the window and the second canvas is located in the left half of the window. The right half of the window; wherein, the first canvas is the part of the canvas used to draw the first part, and the second canvas is the part of the canvas used to draw the second part.
  16. 根据权利要求14或15所述的装置,其特征在于,还包括:修改模块,用于在所述布局模块根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之前,在所述显示屏的第一宽高比在所述阈值区间时,将所述应用程序获取的所述显示屏的宽度修改为所述第二宽度,以使所述用户界面中的元素尺寸小于或等于第一尺寸,所述第一尺寸为所述用户界面在所述显示屏的第二宽高比下显示的元素尺寸,所述第二宽高比小于所述第一宽高比。 The device according to claim 14 or 15, further comprising: a modification module configured to layout the user interface of the application program according to the second width and the second height by the layout module and before obtaining the layout view, When the first aspect ratio of the display screen is in the threshold interval, the width of the display screen obtained by the application program is modified to the second width, so that the element size in the user interface is smaller than Or equal to a first size, which is an element size of the user interface displayed at a second aspect ratio of the display screen, and the second aspect ratio is smaller than the first aspect ratio.
  17. 根据权利要求14至16任一项所述的装置,其特征在于,还包括:The device according to any one of claims 14 to 16, further comprising:
    遍历模块,用于在所述布局模块根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之后,遍历所述用户界面中的元素,判断是否存在第一元素;所述第一元素的顶top坐标值小于所述第一高度,底bottom坐标值大于所述第一高度;A traversal module configured to traverse the elements in the user interface and determine whether the first element exists after the layout module layouts the user interface of the application program according to the second width and the second height and obtains the layout view; The top coordinate value of the first element is less than the first height, and the bottom coordinate value is greater than the first height;
    偏移确定模块,用于确定偏移量和偏移方向,以使所述第一元素整体显示在所述窗口的左半部分或右半部分;An offset determination module, used to determine the offset amount and offset direction so that the first element is displayed as a whole in the left half or the right half of the window;
    第一提供模块,用于将所述偏移量和偏移方向提供给所述应用程序。A first providing module is used to provide the offset amount and offset direction to the application program.
  18. 根据权利要求17所述的装置,其特征在于,所述偏移确定模块还用于当存在所述第一元素时,将|top-h|、|h-bottom|、或|top-h|和|h-bottom|中的较小值作为偏移量;其中,h为所述第一高度;还用于当偏移量为|top-h|时,将向下作为偏移方向;当偏移量为|h-bottom|时,将向上作为偏移方向。The device according to claim 17, wherein the offset determination module is further configured to, when the first element exists, change |top-h|, |h-bottom|, or |top-h| The smaller value of |h-bottom| is used as the offset; where h is the first height; it is also used when the offset is |top-h|, downward is used as the offset direction; when When the offset is |h-bottom|, upward will be used as the offset direction.
  19. 根据权利要求14至18任一项所述的装置,其特征在于,还包括:The device according to any one of claims 14 to 18, further comprising:
    感知模块,用于在所述显示模块通过调整画布,使得所述窗口的左半部分显示所述第一部分,所述窗口的右半部分显示所述第二部分之后,感知用户界面的点击事件;A sensing module configured to sense click events on the user interface after the display module adjusts the canvas so that the left half of the window displays the first part and the right half of the window displays the second part;
    映射模块,用于将所述点击事件从第一位置映射到第二位置;其中,所述第一位置为所述点击事件在所述显示屏右半部分中的位置,所述第二位置为所述第一位置向左偏移所述第二宽度,向下偏移所述第一高度后的位置。A mapping module for mapping the click event from a first position to a second position; wherein the first position is the position of the click event in the right half of the display screen, and the second position is The first position is offset to the left by the second width and is offset downward by the first height.
  20. 根据权利要求14至19任一项所述的装置,其特征在于,还包括:The device according to any one of claims 14 to 19, further comprising:
    第一设置模块,用于在所述布局模块根据第二宽度和第二高度布局所述应用程序的用户界面,得到布局视图之前,在所述窗口的左半部分设置第一区域;所述第一区域用于显示固定内容;A first setting module configured to set a first area in the left half of the window before the layout module layouts the user interface of the application program according to the second width and the second height and obtains a layout view; the first setting module One area is used to display fixed content;
    第二提供模块,用于将所述第一区域的信息提供给所述应用程序。The second providing module is used to provide the information of the first area to the application program.
  21. 根据权利要求20所述的装置,其特征在于,还包括:The device according to claim 20, further comprising:
    第二设置模块,用于在所述窗口的左半部分设置第二区域,所述第二区域位于所述第一区域的下方,所述第二区域显示的内容与所述窗口的右半部分显示的内容关联;The second setting module is used to set a second area in the left half of the window, the second area is located below the first area, and the content displayed in the second area is different from the right half of the window. Relevance of displayed content;
    第二提供模块,用于将所述第二区域的信息提供给所述应用程序。The second providing module is used to provide the information of the second area to the application program.
  22. 根据权利要求14至21任一项所述的装置,其特征在于,所述布局模块还用于:根据第二宽度和第二高度布局包含导航栏的所述用户界面,得到包含导航栏视图的布局视图;所述导航栏视图位于所述第二部分的下方;所述导航栏视图与所述第一部分和所述第二部分的高度之和小于或等于所述第二高度;The device according to any one of claims 14 to 21, characterized in that the layout module is further configured to: lay out the user interface including the navigation bar according to the second width and the second height, and obtain the user interface including the navigation bar view. Layout view; the navigation bar view is located below the second part; the sum of the heights of the navigation bar view, the first part and the second part is less than or equal to the second height;
    所述显示模块还用于:通过调整画布,使得所述导航栏视图在所述窗口中,显示在所述第一部分和第二部分的下方。The display module is also configured to adjust the canvas so that the navigation bar view is displayed below the first part and the second part in the window.
  23. 根据权利要求22所述的装置,其特征在于,所述显示模块还用于:通过放大第三画布,使得所述导航栏视图在所述窗口中,显示在所述第一部分和第二部分的下方。The device according to claim 22, wherein the display module is further configured to: display the navigation bar view in the first part and the second part in the window by enlarging the third canvas. below.
  24. 一种用于显示用户界面的装置,应用于电子设备,其特征在于,包括:A device for displaying a user interface, applied to electronic equipment, characterized by including:
    接收模块,用于接收偏移量和偏移方向;Receiving module, used to receive offset and offset direction;
    规则执行模块,用于根据所述偏移量和偏移方向制定布局规则;a rule execution module, used to formulate layout rules based on the offset and offset direction;
    布局模块,用于根据所述布局规则布局用户界面,以使所述用户界面分左右两部分显示在所述电子设备的显示屏中,且所述用户界面中的元素保持完整。A layout module, configured to lay out the user interface according to the layout rules, so that the user interface is displayed on the display screen of the electronic device in two parts, the left and right parts, and the elements in the user interface remain intact.
  25. 一种用于显示用户界面的装置,应用于电子设备,其特征在于,包括:A device for displaying a user interface, applied to electronic equipment, characterized by including:
    第一接收模块,用于接收第一区域的信息;The first receiving module is used to receive information in the first area;
    第一规则模块,用于根据所述第一区域的信息制定布局规则;A first rule module, configured to formulate layout rules based on the information of the first area;
    第一布局模块,用于根据所述布局规则布局用户界面,以使所述用户界面分左右两部分显示在所述电子设备的显示屏中,且所述第一区域中的内容固定。The first layout module is configured to lay out the user interface according to the layout rules, so that the user interface is displayed in two parts on the display screen of the electronic device, and the content in the first area is fixed.
  26. 根据权利要求25所述的装置,其特征在于,还包括:The device according to claim 25, further comprising:
    第二接收模块,用于接收第二区域的信息; The second receiving module is used to receive information in the second area;
    第二规则模块,用于根据所述第二区域的信息制定布局规则;A second rule module, configured to formulate layout rules based on the information of the second area;
    第二布局模块,用于根据所述布局规则布局用户界面,以使所述第二区域显示的内容与所述用户界面的右部分的内容关联。A second layout module, configured to lay out the user interface according to the layout rules, so that the content displayed in the second area is associated with the content of the right part of the user interface.
  27. 一种电子设备,其特征在于,包括上述权利要求14至23任一项所述的装置。An electronic device, characterized by comprising the device according to any one of claims 14 to 23.
  28. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行权利要求1至13任一项所述的方法。 A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program that, when run on a computer, causes the computer to execute the method described in any one of claims 1 to 13.
PCT/CN2023/111481 2022-08-30 2023-08-07 Method and device for displaying user interface WO2024046041A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211045233.4 2022-08-30
CN202211045233.4A CN117667274A (en) 2022-08-30 2022-08-30 Method and apparatus for displaying user interface

Publications (1)

Publication Number Publication Date
WO2024046041A1 true WO2024046041A1 (en) 2024-03-07

Family

ID=90075668

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/111481 WO2024046041A1 (en) 2022-08-30 2023-08-07 Method and device for displaying user interface

Country Status (2)

Country Link
CN (1) CN117667274A (en)
WO (1) WO2024046041A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100002138A1 (en) * 2008-07-03 2010-01-07 Wistron Corporation Method and system for splitting a display zone of a screen, and computer program product
CN110456951A (en) * 2019-06-26 2019-11-15 华为技术有限公司 A kind of application display method and electronic equipment
CN110569094A (en) * 2019-07-29 2019-12-13 华为技术有限公司 display method and electronic equipment
CN113994317A (en) * 2019-06-19 2022-01-28 华为技术有限公司 User interface layout method and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100002138A1 (en) * 2008-07-03 2010-01-07 Wistron Corporation Method and system for splitting a display zone of a screen, and computer program product
CN113994317A (en) * 2019-06-19 2022-01-28 华为技术有限公司 User interface layout method and electronic equipment
CN110456951A (en) * 2019-06-26 2019-11-15 华为技术有限公司 A kind of application display method and electronic equipment
CN110569094A (en) * 2019-07-29 2019-12-13 华为技术有限公司 display method and electronic equipment
CN114816620A (en) * 2019-07-29 2022-07-29 华为技术有限公司 Display method and electronic equipment

Also Published As

Publication number Publication date
CN117667274A (en) 2024-03-08

Similar Documents

Publication Publication Date Title
US11048404B2 (en) Information processing apparatus, information processing method, and program
JP4533943B2 (en) Information processing apparatus, display control method, and program
US10310730B2 (en) Display device for controlling displaying of a window and method of controlling the same
US7441204B2 (en) Method and system for automatically displaying content of a window on a display that has changed orientation
US9071870B2 (en) System and method for viewing digital visual content on a device
US20110283228A1 (en) Information processing apparatus and method, and program
US20150227308A1 (en) User terminal device and method for displaying thereof
CN110347317B (en) Window switching method and device, storage medium and interactive intelligent panel
US20110202834A1 (en) Visual motion feedback for user interface
KR102132390B1 (en) User terminal device and method for displaying thereof
US20150109343A1 (en) Zoom processing device, zoom processing method, and computer program
WO2013139089A1 (en) Screen content zoom-in and displaying method and terminal
JP2006505025A (en) Graphical user interface for expandable menus
JP2008250948A (en) Information processing device, information processing method, information processing program, storage medium recording information processing program, and information display device
JP2012008686A (en) Information processor and method, and program
CN112558951B (en) Foldable screen webpage adaptation method, device and storage device
JP2007122633A (en) Information display control device and information display control program
WO2023155811A1 (en) Page layout adjustment method and apparatus
JP2014035496A (en) Display device, control method of display device, and program
JP5880024B2 (en) Information processing apparatus and program
WO2024046041A1 (en) Method and device for displaying user interface
WO2024021813A1 (en) Screenshot taking method and apparatus, electronic device and storage medium
US20180173411A1 (en) Display device, display method, and non-transitory computer readable recording medium
CN104715053B (en) Implementation method, device and the browser that web page contents are shown
JP4179810B2 (en) Display data creation device, display data creation method, display data creation program, and computer-readable recording medium on which display data creation program is recorded

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23859076

Country of ref document: EP

Kind code of ref document: A1