Method for displaying interface and electronic device
By dynamically adjusting screen density and managing window information in electronic devices, the occlusion and squeezing problems in user interface display are solved, and the user experience and execution efficiency are improved.
Patent Information
- Application Number
- CN202411230294.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-04
AI Technical Summary
When an electronic device displays a user interface, some information is easily blocked or squeezed, resulting in poor user interaction experience. The existing technology has failed to effectively solve this problem.
By creating and managing windows in electronic devices, we can determine whether the child view exceeds the parent view area, dynamically adjust the screen density to avoid occlusion and squeezing, and ensure that the interface is fully displayed. Specific methods include traversing the view tree, obtaining window information, adjusting mark bit management, and restarting the application to maintain density consistency.
It effectively avoids occlusion and squeezing problems in interface display, improves user experience, and ensures interface integrity and execution efficiency.
Smart Images

Figure CN118733184B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of terminal devices, and in particular to a method for displaying an interface and an electronic device. Background Art
[0002] When an electronic device displays the user interface (UI) of an application, the screen of the electronic device should fully display the content of the entire user screen to ensure that the user can interact with the device smoothly. However, in some display situations, the user interface of the application displayed by the electronic device has some information blocked and squeezed, and the electronic device cannot clearly and completely display the application interface, resulting in a poor interaction experience between the user and the device. Summary of the invention
[0003] The embodiments of the present application provide a method for displaying an interface and an electronic device, which can be used to prevent display objects in a user interface from being blocked, ensure the integrity of the interface display, and improve the user experience.
[0004] In a first aspect, an embodiment of the present application provides a method for displaying an interface and an electronic device, the method being applied to an electronic device, comprising: the electronic device displays a first user interface, the first user interface being a desktop interface; in response to a first operation acting on the first user interface, the electronic device creates a first window; the first operation is an operation of starting a first application; the first window is a window of the user interface of the first application; the screen density of the first window is a first value; when the area of the first view exceeds the area of the second view, the electronic device sets the screen density of the first window to a second value; the first window includes the first view and the second view, the first view being a subview of the second view; the electronic device displays the first window.
[0005] Among them, the first value is different from the second value, and the screen density is Figure 6 and Figure 8 The first density in.
[0006] In the embodiments of the present application, the electronic device avoids the problem of occlusion and crowding out of display objects caused by the application manufacturer's failure to adapt the processing, ensures the integrity of the display, and improves the user experience.
[0007] In a possible implementation, the method further includes: in response to a second operation on the first user interface, the electronic device creates a second window; the second operation is an operation of starting a second application; the screen density of the second window is a third value; in the absence of an area where the third view exceeds an area where the fourth view exists, the electronic device displays the second window, and the screen density of the second window remains at the third value; the second window includes the third view and the fourth view, and the third view is a subview of the fourth view. In this way, in the absence of an area where the third view exceeds an area where the fourth view exists, the electronic device can keep the screen density unchanged at the third value, and when it is determined that the screen can be fully displayed, the screen density is not adjusted (the screen density determined last time is inherited), and the screen is kept as close to the original layout of the application interface as possible, thereby reducing the processing process and improving execution efficiency.
[0008] In a possible implementation, the method further includes: in response to the first operation, the electronic device obtains window information of the first window; the electronic device traverses the first viewtree and determines whether the area of the subview in the first viewtree exceeds the area of the parent view based on the window information; the first viewtree is used to describe the view structure of the first window. In this way, the electronic device can ensure the accuracy of the judgment that the area of the first view exceeds the area of the second view by traversing the first viewtree and determining whether the area of the subview in the first viewtree exceeds the area of the parent view based on the window information, thereby effectively screening out incomplete display situations and ensuring the accuracy of adjusting the screen density.
[0009] The window information is used to describe the display position and size of the first window on the screen of the electronic device.
[0010] In a possible implementation, after the electronic device creates the first window, the method further includes: the electronic device obtains the window information of the first window; when the adjustment mark of the first application is not the first mark, the electronic device traverses the first viewtree, and determines whether the area of the subview in the first viewtree exceeds the area of the parent view based on the window information. In this way, the electronic device can reduce the processing process of traversing and determining whether the area of the subview exceeds the area of the parent view by determining the adjustment mark, ensure the validity after the screen density is adjusted or after traversal, no longer repeat the traversal, improve execution efficiency, and save processing resources.
[0011] In a possible implementation, when the adjustment mark of the first application is the first mark, the electronic device determines not to set the screen density of the first application. In this way, when the adjustment mark of the first application is the first mark, the electronic device does not adjust the screen density and directly displays the application interface to improve execution efficiency.
[0012] In a possible implementation, after the electronic device sets the screen density of the first window to a second value, the method further includes: the electronic device sets the adjustment flag of the first application to the first flag, and stores the screen density of the first application as the second value. In this way, after the screen density is adjusted, the adjustment flag can be set to the first flag, which reduces the subsequent traversal and adjustment processing of the screen density, improves processing efficiency, reduces processing resources, and ensures memory performance.
[0013] In a possible implementation, after the electronic device traverses the first viewtree and determines based on the window information whether the area of the subview in the first viewtree exceeds the area of the parent view, the method further includes: the electronic device sets the adjustment mark of the first application to the first mark. In this way, after determining whether the area of the subview in the first viewtree exceeds the area of the parent view, the adjustment mark is set to the first mark regardless of whether the screen density is adjusted or not, thereby reducing the subsequent traversal and adjustment processing of the screen density, improving processing efficiency, reducing processing resources, and ensuring memory performance.
[0014] In a possible implementation, after the electronic device sets the screen density of the first window to the second value, the method further includes: the electronic device restarts the first application and determines whether the adjustment mark of the first application is the first mark; when the adjustment mark of the first application is the first mark, the screen density of the first window displayed by the electronic device is the second value. In this way, after the electronic device adjusts the screen density, restarting the first application can ensure that the adjusted second value is used immediately, avoid the situation where the current display object is blocked, improve the display effect, and ensure user experience.
[0015] In a possible implementation, the child view in the first viewtree of the first window is any view in the first viewtree; when the first view is the root view of the first viewtree, the second view is the first window. In this way, all views of the first viewtree of the first window can be traversed to ensure that the entire interface is within the first window, thereby ensuring the accuracy and reliability of determining whether the scope is exceeded.
[0016] In a possible implementation, the electronic device obtains window information of the first window, including: the electronic device determines the window mode and display scene of the first window; the window mode includes one of full screen, split screen, floating window and parallel view, and the display scene represents the display direction and display screen of the electronic device; the electronic device determines the window information based on the screen size, the window mode and the display scene, and the window information represents the size and position of the first window display.
[0017] In this way, under different screen display conditions, the electronic device needs to determine the window situation in a timely manner to ensure the accuracy of the judgment basis, thereby ensuring the accuracy of the judgment result, accurately avoiding the current display object from being blocked, improving the display effect, and ensuring user experience.
[0018] In a possible implementation, the electronic device includes an activity manager AMS, a window manager WMS, a view system and a choreographer, and in response to a first operation acting on the first user interface, the electronic device creates a first window, including: in response to the first operation acting on the first user interface, the first application sends a create activity request to the AMS, and the AMS creates a first activity; the AMS sends a window creation request to the WMS; the WMS creates a first window; the electronic device obtains window information of the first window, including: the view system obtains window information of the first window; when the adjustment mark bit of the first application is not the first mark, the electronic device traverses the first viewtree, and based on the window information, determines whether there is an area of a child view in the first viewtree that exceeds the area of a parent view, including: the electronic device determines whether the adjustment mark bit of the first application is the first mark, and in the case where the adjustment mark bit of the first application is not the first mark, When the adjustment mark bit used is not the first mark, the first viewtree is traversed, and based on the window information, it is determined whether there is a child view in the first viewtree whose area exceeds the parent view; when the area of the first view exceeds the area of the second view, the electronic device sets the screen density of the first window to a second value, including: when the area of the first view in the first viewtree exceeds the area of the second view, the view system sets the screen density of the first window to a second value; the electronic device sets the adjustment mark bit of the first application to the first mark, including: the view system sets the adjustment mark bit of the first application to the first mark; the electronic device displays the first window, including: the view system draws the view of the first window; the view system sends a display request to the choreographer; the choreographer renders and synthesizes the first window, and then displays the first window. In this way, the electronic device avoids the problem of occlusion and crowding of display objects caused by the application manufacturer's failure to adapt, ensures the integrity of the display, and improves the user experience.
[0019] In a possible implementation, the method further includes: after the electronic device displays the first window, in response to a third operation acting on the first user interface, the electronic device creates a third window; the third operation is an operation of starting the first application; the screen density of the second window is a second value; in the absence of an area of the fifth view exceeding an area of the sixth view, the electronic device displays the third window, and the screen density of the third window remains at the second value; the third window includes the fifth view and the sixth view, and the fifth view is a subview of the sixth view.
[0020] In a second aspect, an embodiment of the present application provides an electronic device, comprising one or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program code, the computer program code comprises computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes a method for displaying an interface as described in the first aspect or any possible implementation method of the first aspect.
[0021] In a third aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on an electronic device, enables the electronic device to execute a method for displaying an interface as described in the first aspect or any possible implementation of the first aspect.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enable the electronic device to execute a method for displaying an interface as described in the first aspect or any possible implementation of the first aspect.
[0023] In the fifth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions to enable the electronic device to execute a method of displaying an interface as described in the first aspect or any possible implementation method of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1A It is a structural diagram of a ViewTree provided in an embodiment of the present application;
[0025] Figure 1B is a schematic diagram of a view structure of an application window provided in an embodiment of the present application;
[0026] Figure 2 is a schematic diagram of a screen size representation provided by an embodiment of the present application;
[0027] Figure 3 It is a schematic diagram of the hardware structure of a group of electronic devices provided in an embodiment of the present application;
[0028] Figure 4 It is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0029] Figure 5A to Figure 5F is a set of user interface schematic diagrams provided in an embodiment of the present application;
[0030] Figure 6This is a flow chart of an interface display method provided in an embodiment of the present application;
[0031] Figure 7 is a schematic diagram of a user interface provided in an embodiment of the present application;
[0032] Figure 8 This is a flow chart of a method for interface display provided in an embodiment of the present application;
[0033] Fig. 9A and Fig. 9B It is a process diagram of a group of display interface methods provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiments may be included in at least one embodiment of the present embodiment application. The appearance of this phrase in various positions in the specification is not necessarily the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It can be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0035] The terms "first", "second", "third", etc. in the specification and claims of the present application and the drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a series of steps or units are included, or optionally, steps or units not listed are included, or optionally, other steps or units inherent to these processes, methods, products or devices are included.
[0036] Only the part relevant to the present application is shown in the accompanying drawings, but not all of the content. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the operations (or steps) as sequential processes, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings.
[0037] The following are the concepts related to this application:
[0038] 1. DecorView, ViewGroup and View
[0039] The view structure of the Android system adopts a composite mode, that is, View is the base class of all graphics, and ViewGroup inherits and extends View to become a view container class, so the basic structure of the view part is a tree structure.
[0040] A complete user interface is represented by a window. Window is an abstract concept from the perspective of WMS. All views in the Android system are presented through Window. Window can load a super composite View, namely DecorView, which can include all Views in the window. The view structure of DecorView is a tree structure, namely ViewTree, with the top-level ViewGroup. Among them, ViewGroup and View are the basic components of ViewTree, namely nodes in ViewTree. ViewGroup can include ViewGroup and / or View.
[0041] Figure 1A Schematic diagram of a ViewTree structure disclosed in an exemplary embodiment of the present application. Any user interface of the application needs to correspond to a ViewTree that describes the layout structure, such as Figure 1A As shown, DecorView is the root node of the ViewTree, and the root node DecorView includes at least one ViewGroup and / or at least one View. The DecorView includes ViewGroup1 and View1, and ViewGroup1 includes View2 and View3. Among them, DecorView is the parent node of ViewGroup1 and View1, and ViewGroup1 and View1 are the child nodes of DecorView; ViewGroup1 is the parent node of View2 and View3, and View2 and View3 are the child nodes of ViewGroup1. The above ViewGroup and View are nested and combined in a tree structure to form a ViewTree.
[0042] Among them, each node of ViewTree can correspond to its declaration information, and the declaration information can include the layout information of the component in the display window, etc. In the tree structure, the position and size of the child View in its parent View can indicate the position and size of the View in the ViewGroup. Among them, the layout information of each node in ViewTree can include size information, etc. For example, the size information can be the pixel size of the width and height of the View or ViewGroup; it can also be the ratio of the width and height of the node relative to its parent node, etc. This application does not limit the specific expression of the size information.
[0043] like Figure 1B The figure shows a schematic diagram of a view structure of an application window provided by the present application. Figure 1B As shown, the user interface of the application is displayed in full screen as an example Figure 1A The user interface corresponding to ViewTree in . View is the basic building block of the user interface component, which can occupy a rectangular area on the screen and is used to enable the application to interact with the user. ViewGroup is also a rectangular area, and the rectangular area of its child nodes can be displayed in the rectangular area of ViewGroup. Among them, DecorView can be displayed in full screen, and the corresponding position and size of the root node are consistent with the display window of the screen, for example, the resolution is 1280*720. ViewGroup1 and View1 can be displayed in DecorView. View2 and View3 can be displayed in ViewGroup1. The layout information of each node can be the positional relationship between its rectangular area and the rectangular area of the parent node. For example, the layout information of the View2 node is the distance between the four sides of the View2 rectangular area and the corresponding four sides of the ViewGroup1 rectangular area, for example, the first distance L1 between the upper side of the View2 rectangular area and the upper side of the ViewGroup1 rectangular area; the second distance L2 between the lower side of the View2 rectangular area and the lower side of the ViewGroup1 rectangular area; the third distance L3 between the left side of the View2 rectangular area and the left side of the ViewGroup1 rectangular area; the fourth distance L4 between the right side of the View2 rectangular area and the right side of the ViewGroup1 rectangular area.
[0044] 2. Screen Size Bounds
[0045] The screen size Bounds can represent the height and width of the screen. The screen size can be represented by four distance information or two coordinate information. Figure 2 Specific instructions.
[0046] Figure 2 is a schematic diagram of a screen size representation provided by an embodiment of the present application. Figure 2As shown, the screen size can be determined according to the coordinates. Starting from the coordinate origin, the rightward direction is the direction of increasing X axis, and the downward direction is the direction of increasing Y axis (the X axis and Y axis are perpendicular to each other). Figure 2 As shown, the screen size can be expressed as (x1, x2, y1, y2), where x1 is the distance from the left side of the screen rectangle to the Y axis, and x2 is the distance from the right side of the screen rectangle to the Y axis; y1 is the distance from the top of the screen rectangle to the X axis, and y2 is the distance from the bottom of the screen rectangle to the X axis. Optionally, the screen size can also be expressed as two coordinates (x1, y1) and (x2, y2), where (x1, y1) is the coordinate of the upper left corner of the screen rectangle, and (x2, y2) is the coordinate of the upper right corner of the screen rectangle; the screen width is x2-x1, and the screen height is y2-y1. Generally, the upper left corner of the screen is taken as the origin, that is, x1 and y1 are both 0.
[0047] 3. Screen density
[0048] Screen density is a measure of screen quality, indicating the number of pixels per unit area, that is, how many pixels there are per inch, in dpi (dots per inch), such as 300-480dpi (DPI value). In the Android system, screen density and device resolution affect the display effect. The higher the screen density value, the higher the display can display images, making the picture details more delicate.
[0049] The concept of screen density is closely related to the resolution and size of the screen. Resolution refers to the total number of pixels on the screen, while screen size is measured in inches. Pixel density measures the clarity and fineness of the display by calculating the number of pixels per inch of the screen. A higher pixel density means that more pixels can be accommodated under the same screen size, making the image clearer and more detailed.
[0050] The electronic device in the embodiments of the present application can be a laptop computer, a desktop computer, a mobile phone, a tablet computer, a desktop computer, a handheld computer, a smart bracelet, a super mobile personal computer, a netbook, a personal phone, a personal data assistant, an augmented reality (AR) / virtual reality (VR) and other touch screen devices. The present application does not limit the specific form of the electronic device.
[0051] The following is an introduction to the device involved in the embodiments of the present application.
[0052] Figure 3 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application.
[0053] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0054] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.
[0055] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0056] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0057] The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area.
[0058] It is understandable that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0059] The electronic device implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0060] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0061] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it.
[0062] In the embodiment of the present application, the electronic device 100 can detect user operations through the touch sensor 180K. The user operation may include a touch event from the user touching the display screen 194. For example, the electronic device displays a desktop interface, and the user clicks on an application icon on the desktop interface. In response to the operation, the application is started, and the electronic device displays the user interface of the application. The touch operations corresponding to the touch events involved in this application can be referred to Figure 5A to Figure 5C The relevant content in will not be repeated here.
[0063] Optionally, the above-mentioned operation method only takes touch operation as an example, and the operation of the present application can also be air gesture operation, or voice control, etc., without limitation.
[0064] Figure 4 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application.
[0065] like Figure 4 As shown, the software framework of the electronic device involved in the present application may include an application layer (Application), an application framework layer (framework, FWK) and an Android runtime (Android runtime) and a system library.
[0066] The application layer may include a series of application packages. For example, desktop (Launcher), weather, memo, calendar, social software and other applications (may also be referred to as applications, some of the above applications are not shown). In the embodiment of the present application, the first application may be any application in the application layer, the user may open the first application (the first application is a non-desktop application), and the electronic device may display the user interface of the first application.
[0067] The desktop is one of the main program components in the Android system. The electronic device starts the application of the Android desktop through the Launcher, or exits the application to display the desktop.
[0068] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0069] like Figure 4As shown, the application framework layer may include a window manager service (WMS), an activity manager service (AMS), a content provider, a resource manager, and a view system (view), etc.
[0070] The window management service is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0071] Among them, a window can be understood as an area on the screen where the user interface (UI) is displayed for user interaction. From the system's perspective, a window is a canvas (surface). A screen can have multiple windows, and the layout and order of these multiple windows and window animations are managed by the window management service WMS. For example, Figure 5A Desktop applications in can include windows such as the negative first screen, icons, wallpapers, and status bar.
[0072] AMS is a service in the Android system that manages and schedules the life cycle and task stack of activities. AMS manages the life cycle of activities by using system resources and data structures (such as processes, task stacks, and recording the status of the life cycle of activities). For example, it manages the creation, operation, and destruction of the life cycle of applications.
[0073] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0074] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0075] The view system includes the View framework, which includes ViewRootImpl. The View framework manages the layout and drawing of view objects. ViewRoot can manage the view tree ViewTree, which is mainly used to communicate with WMS.
[0076] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0077] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL) and choreographer (SurfaceFlinger).
[0078] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of multiple common audio and video formats, as well as static image files. The media library can support multiple audio and video encoding formats. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.
[0079] SurfaceFlinger is responsible for managing and rendering the surfaces of all graphical interfaces. SurfaceFlinger can render, synthesize, and display images of the user interface.
[0080] It should be noted that the application provides Figure 4 The software structure diagram of the electronic device shown is only an example and does not limit the specific module division in different layers of the Android operating system. For details, please refer to the introduction of the Android operating system software structure in conventional technology. In addition, the display method provided by this application can also be implemented based on other operating systems, and this application will not give examples one by one.
[0081] The scenario addressed by the embodiments of the present application is a scenario in which an electronic device displays a first application. Figure 5A to Figure 5F Several situations in which a display screen is blocked when an electronic device displays a user interface of a first application starting from a user interface of a desktop application are described.
[0082] Figure 5A to Figure 5F It is a set of user interface schematic diagrams exemplarily disclosed in the embodiments of the present application.
[0083] Case 1: When the application is started, information in the application interface is blocked.
[0084] The user turns on the electronic device, and the electronic device can display the desktop interface. Figure 5A is a schematic diagram of the desktop interface of a user of an electronic device. Figure 5A As shown, the electronic device can display icons of applications such as clock, calendar, gallery, memo, file management, email, music, calculator and smart home 511. The user can click the application icon of smart home 511, and in response to the operation of clicking the icon of smart home 511, as shown in FIG. Figure 5BAs shown, the electronic device can display the user interface of the smart home. The first application mentioned above takes the smart home as an example.
[0085] There are many types of electronic devices, and the corresponding resolutions and screen aspect ratios may be different. However, the application interfaces of some manufacturers are not adapted to screen sizes of different resolutions or display window sizes. When displaying the interface of a certain application on devices with different screen sizes, some display object icons may squeeze each other or display information may be blocked.
[0086] Figure 5B Schematic diagram of a user interface of a smart home disclosed in an exemplary embodiment of the present application. Figure 5B As shown, when the user starts the first application, in response to the interface of starting the first application, the electronic device can display the following Figure 5B A user interface in which the display objects of the first application "TV in the second bedroom" 521 and "speaker in the living room" 522 are partially blocked, the icon information is not fully displayed, the user cannot view all the information, and the user experience is poor.
[0087] Case 2: The display direction is switched, and the information in the application interface is blocked after the switch.
[0088] The electronic device supports user interfaces and horizontal and vertical screen displays for different applications. The application interface can only adapt to the display in one direction, and the other display direction may have problems such as icon crowding. For example, Figure 5C and Figure 5D This is a set of user interface schematic diagrams shown in an embodiment of the present application.
[0089] like Figure 5C As shown, when the electronic device displays the user interface of the first application in landscape mode, the electronic device can display the first application in split screen, with the home menu displayed in the left split screen area and the smart control interface of a home in the right split screen area. Figure 5C As shown, the smart control interface of the "Living Room Speakers" in the home menu is displayed in the right split-screen area. Users can control the speakers in the living room and then control music playback by operating the smart control interface. Figure 5C Both sides of the split screen are fully displayed without any obstruction or crowding.
[0090] When the user wants to use the electronic device in portrait mode, the user can rotate the electronic device so that the portrait mode of the electronic device faces the user. When the electronic device switches from landscape mode to portrait mode, the user can display Figure 5D If the manufacturer of the application does not specifically adapt the vertical screen interface for the electronic device of this model, when the user interface of the first application is displayed in vertical screen, there may be partial obstruction and crowding of the displayed object. Figure 5DAs shown, in the smart device, due to the adaptive adjustment of icons by the electronic device, part of the information and images in the display objects of “speakers in the living room” 541, “speakers in the master bedroom” 542, and “speakers in the second bedroom” 543 are blocked.
[0091] Optionally, the user may also switch from the portrait screen interface to the landscape screen interface and some information and images of the displayed object may be blocked, which is not limited in this application.
[0092] Among them, the electronic device in situation 2 is generally a foldable device or a tablet device, and the electronic device can display the application interface in different display directions of the screen. This application does not limit the specific device type.
[0093] Case 3: The display screen is switched, and the information is blocked after the display screen is switched.
[0094] like Figure 5E and Fig. 5F 1 is a user interface diagram of different screens of a foldable device exemplarily disclosed in an embodiment of the present application. The electronic device may include at least a first screen and a second screen.
[0095] like Figure 5E As shown, when the electronic device is in the folded state, the first screen of the electronic device is in a visible state. When the first screen displays the first application, the size of the first screen of the electronic device can adapt to the application interface of the first application, so that the electronic device can fully display the first application.
[0096] like Fig. 5F As shown, when the electronic device is in the unfolded state, the second screen is visible. When the second screen displays the first application, the electronic device adaptively adjusts the display object. Since the size of the second screen cannot adapt to the application interface of the first application, part of the information and pictures in the display objects of "smart projector" 561 and "router" 562 are blocked in the interface of the first application displayed on the second screen.
[0097] Case 4: The application is displayed in split screen, and the information is blocked after the split screen.
[0098] Some electronic devices have a split-screen function. The proportion of applications displayed on the screen changes before and after splitting the screen. Therefore, some icons may not be fully displayed after splitting the screen.
[0099] It should be noted that the above Figure 5A to Figure 5F In the example, the obstruction of the display object in the application interface displayed by the electronic device is only an exemplary description, and there may also be problems such as pop-up window display, too large layout, etc. that cause the display object to be incomplete. This application does not constitute a limitation on a certain application or a certain display object.
[0100] In the above-mentioned situations, since some application manufacturers have not adapted user interfaces to different screen sizes or special display ratios in advance, when electronic devices display the user interfaces of these applications, due to the incompatibility of screen size or display size in the application interface display, problems such as icons occupying each other, being incompletely displayed, or being too large in the interface occur, resulting in poor browsing and operating experience for users using these applications.
[0101] Based on the above problems, the embodiments of the present application propose an interface display method and an electronic device. In this method, the electronic device can determine whether there is an icon crowding problem during the application startup process. If there is an icon crowding problem, the screen density can be adjusted to ensure that no icons are blocked, and then the display is performed according to the adjusted density. When the screen density of the application has been adjusted or it has been determined that it does not need to be adjusted, the user interface can be displayed in a corresponding manner. In the above process, since the electronic device determines the current target density before displaying the user interface, it is ensured that in the subsequent display process, there will be no crowding and occlusion of the display object, ensuring a complete display and improving the user experience.
[0102] Based on the above technical problems, an interface display method is specifically described below.
[0103] Figure 6 This is a flow chart of an interface display method disclosed in an embodiment of the present application. Figure 6 As shown, the interface display method of the electronic device may include but is not limited to the following steps:
[0104] S601: When starting a first application, the electronic device obtains window information based on the window mode and the screen size.
[0105] In response to a first operation on a desktop interface, the electronic device may create a process of a first application, create a first window, and determine window information of the first window. The first window is a window of a user interface of the first application. The window information is used to describe the position and size of the first window displayed on the screen. For example, the window information includes two coordinate information, a first coordinate (x1, y1) and a second coordinate (x2, y2), which may represent a rectangular area displayed by the first window. The value of the second coordinate on the X-axis is greater than the value of the first coordinate on the X-axis, and the value of the second coordinate on the Y-axis is greater than the value of the first coordinate on the Y-axis; that is, x2 is greater than x1, and y2 is greater than y1.
[0106] The electronic device may determine the window information of the first window. Two possible implementations are described below:
[0107] In a possible implementation, the electronic device obtains a window mode and a screen size of the first window, and then determines the window information based on the window mode and the screen size.
[0108] Among them, the window mode is the display mode of the application window on the whole machine screen, which can indicate the display relationship between the window and the screen. The current window mode is full screen, split screen, floating window, parallel horizon and other scenes. Among them, full screen is a mode in which the interface of an application is displayed on the whole screen. Split screen is used for scenarios where two or more applications are processed in parallel for a long time, that is, the whole screen can display the interfaces of multiple applications. For example, top and bottom split screen and left and right split screen, etc. The floating window is used to temporarily process another task on the basis of the existing task-based task, or to use multiple tasks in parallel for a short time, that is, one or more floating windows can be displayed on the screen. Parallel horizon is an interface that uses the interface as the basic unit to realize the dual-window display within the application.
[0109] The screen size refers to the current screen size or the coordinates that can represent the screen size.
[0110] After the window mode of the current electronic device is obtained, the window information of the first window displayed in the electronic device can be determined based on the window mode. When the electronic device is in full-screen mode, the window information of the first window can be the screen information of the full screen or the window information of the full screen; when the electronic device is in split-screen mode, the window information of the first window can be the window information of the split-screen window where the first window is located; when the electronic device is in floating window mode, the window information of the first window can be the window information of the floating window where the first window is located; when the electronic device is in parallel horizon mode, the window information of the first window can be the window information of the window in the parallel horizon.
[0111] In another possible implementation, the electronic device obtains the window mode, display scene, and screen size of the first window, and then determines the window information based on the window mode, display scene, and screen size.
[0112] The display scene can be used to indicate the display direction and / or display screen. The display direction includes horizontal display and vertical display; when the electronic device includes two or more screens, the display screen can indicate the currently displayed screen, and the screen sizes may be different.
[0113] The electronic device may be based on the screen size, window mode and display scene. Wherein, the acquisition method of the window mode and the screen size can refer to the above-mentioned related description, which is not repeated. Afterwards, the electronic device may determine the window information of the first window based on the screen size, window mode and display scene.
[0114] S602: The electronic device determines whether the adjustment mark of the first application is the first mark. If the adjustment mark of the first application is the first mark, S607 is executed; if the adjustment mark of the first application is not the first mark (the adjustment mark is the second mark or no mark), S603 is executed.
[0115] The adjustment flag is used to mark whether it is necessary to perform the process of traversing subviews and determining whether the subview is smaller than the parent view (S603-S605). In one possible case, if the screen density of the first application has been set, the adjustment flag of the first application has been set to the first flag; in another possible case, if the process of traversing subviews and determining whether the subview is smaller than the parent view has been performed on the first window of the first application, the adjustment flag of the first application has been set to the first flag.
[0116] In a possible implementation, the electronic device may directly determine whether the adjustment mark of the first application is the first mark and execute S602. The first mark is true. When the adjustment mark is determined to be true, execute S607; when the adjustment mark is determined to be false or there is no mark, execute S603 to S605.
[0117] In another possible implementation, the electronic device may include an application whitelist, and the adjustment flag of the application in the application whitelist is the first flag. The application whitelist is an application that does not need to determine whether to adjust the screen density. Based on the above two situations where the adjustment flag is set to the first flag, the following are respectively described:
[0118] In one possible case, the application whitelist includes two types of applications, one of which is an application whose screen density has been adjusted. The electronic device has calculated the screen density of the application, and the application whitelist stores the application name and screen density of each application in the application.
[0119] In another possible case, the application whitelist includes two types of applications, one is the application whose screen density has been adjusted, and the other is the application whose screen density has not been adjusted and does not need to be adjusted. The application that has been adjusted is that the electronic device has calculated the screen density of this type of application, and the application whitelist stores the application name and screen density of each application in this type of application. The application whose screen density has not been adjusted and does not need to be adjusted is that the complete application interface can be displayed without adjusting the screen density. The application whitelist stores the application name of this type of application, and can also store the type information of this type of application. The type information can indicate that this application does not need to adjust the screen density and can be directly displayed according to the current parameters.
[0120] The electronic device determines whether the adjustment mark bit of the first application is the first mark by determining whether the first application is included in the application whitelist. When the application name in the application whitelist includes the application name of the first application, the adjustment mark bit of the first application is determined to be the first mark, and the electronic device can directly obtain the first screen density of the first application, and then S607 can be executed. When the application name in the application whitelist does not include the application name of the first application, it is determined that the adjustment mark bit of the first application is not the first mark (no mark or the second mark), that is, S603~S605 are executed.
[0121] Wherein, when the application name in the application whitelist includes the application name of the first application, the electronic device can directly obtain the first screen density of the first application. If the first application is an application that has been adjusted, the screen density corresponding to the first application stored in the application whitelist is the first screen density; if the first application is an application whose screen density has not been adjusted and does not need to be adjusted, the default screen density of the first application is the first screen density.
[0122] Exemplarily, the application whitelist stored in the electronic device is application A, application B, and application C, wherein application A stores density A, application B stores density B, and application C does not store density. At this time, application A and application B are applications that have been adjusted, and application C is an application whose screen density has not been adjusted and does not need to be adjusted. When the first application is application D, the electronic device determines that the application whitelist does not include application D, then it is necessary to determine whether to adjust the screen density of the first application, and execute S603~S605. When the first application is application A, the electronic device determines that the application whitelist includes application A, then obtains the screen density densityA of application A in the application whitelist, and then executes S607. When the first application is application C, the electronic device determines that the application whitelist includes application C, and the screen density of application C is not stored in the application whitelist, and S607 can be directly executed by defaulting to the screen density of the first application.
[0123] In the above S602, judging in advance whether S603 to S605 need to be processed can reduce the traversal judgment process, ensure the validity after the screen density is adjusted or after traversal, avoid repeated traversal, improve execution efficiency, and save processing resources.
[0124] The screen density is the screen density density, the first screen density is the first density, and the specific description of the screen density density can refer to the introduction of the screen density in the terms related to the above-mentioned prior art, which will not be repeated here.
[0125] S603 to S605 are the process of traversing the view tree (ViewTree) of the first application and determining whether there is a sub-view area that exceeds the parent view area. This will be specifically described through S603 to S605 below.
[0126] S603: The electronic device obtains the first sub-view.
[0127] The electronic device can traverse the first view tree (ViewTree) of the first application, that is, start from the root view of the ViewTree and sequentially determine the first sub-view in the order of the first view tree structure. The first sub-view is each node of the first ViewTree. When obtaining the first sub-view for the first time, it can be determined that the first sub-view is the root view. The parent view of the root view is determined as the first window.
[0128] After executing S605, the first sub-view is determined to be the next node of the first sub-view in S605 in the first view tree. Exemplarily, the first ViewTree includes a total of K nodes, where K is an integer greater than 2. When the first sub-view is the i-th node in the first ViewTree in S605 (i < K), the first ViewTree obtained in S603 is the (i + 1)-th node. When the first sub-view is the K-th node in the first ViewTree, it is determined that the traversal ends.
[0129] S604: The electronic device determines whether the area of the first sub-view exceeds the area of the first parent view. If the area of the first sub-view does not exceed the area of the first parent view, S605 is executed; if the area of the first sub-view exceeds the area of the first parent view, S606 is executed.
[0130] The electronic device can obtain the first coordinate information of the first sub-view and the second coordinate information of its first parent view, and can determine whether the area of the first sub-view exceeds the area of the first parent view based on the first coordinate information and the second coordinate information. Among them, the first coordinate information and the second coordinate information can represent the position and size of the first sub-view in the first window on the display screen.
[0131] Exemplarily, the first coordinate information of the first sub-view is (a1, b1), and the second coordinate information of the first sub-view is (c1, d1); the first coordinate information of the first parent view is (a2, b2), and the second coordinate information of the second sub-view is (c2, d2). When a1 is less than or equal to a2, b1 is less than or equal to b2, c1 is less than or equal to c2, and d1 is less than or equal to d2, it is determined that the area of the first sub-view does not exceed the area of the first parent view; otherwise, the area of the first sub-view exceeds the area of the first parent view.
[0132] The first child view and the first parent view are the child node and the parent node in the first ViewTree. The first ViewTree is used to describe the view structure of the first window.
[0133] When the first subview is the root view, the size of the parent view of the first subview is the window information of the first window. When the area of the root view is within the window area, it can be determined that the area of the first subview does not exceed the area of the first parent view.
[0134] S605: The electronic device determines whether the first subview is the last subview. If the first subview is the last subview, S607 is executed; if the first subview is not the last subview, S603 is executed.
[0135] In S603, the electronic device has determined the number of nodes K of the first ViewTree, and the current first sub-view is the i-th node in the first ViewTree. It determines whether i is greater than or equal to K. When i is greater than or equal to K, it determines that the first sub-view is the last sub-view and the traversal is completed; when i is less than K, it determines that the first sub-view is not the last sub-view, the traversal has not yet been completed, and the process of S603~S605 continues to be executed.
[0136] Optionally, when the first sub-view is the last sub-view, it can be determined that the screen density of the first application does not need to be adjusted. Therefore, the electronic device also needs to store the application name (package name) of the first application in the application whitelist, and determine that the type of the first application is an application whose screen density has not been adjusted and does not need to be adjusted. At this time, the default density of the first application is the first density.
[0137] S606: The electronic device sets a value of the first density, and stores the value of the first density of the first application.
[0138] When it is determined in S604 that the first child view is not smaller than the first parent view, the electronic device may set a value of the first density of the first application and store the value of the first density of the first application.
[0139] Specifically, the electronic device may determine the first density according to the preset density information, wherein the first density is greater than the value of the density of the current first application, for example, adjusting the first density from the first value to the second value.
[0140] Electronic devices can increase the screen density. When the screen resolution is fixed, the larger the screen density, the more pixels can be accommodated under the same screen size, that is, the physical size of a subview becomes smaller, and the subview that is blocked or occupied can be fully displayed, ensuring the integrity of the display.
[0141] Exemplarily, the display range of the screen density is 300-480 dpi, the current screen density of the first application is 300 dpi, and the preset screen density is 360 dpi. The electronic device can set the first density to 360 dpi.
[0142] For example, the electronic device may be provided with screen densities of different levels, and the first density may be set to increase the screen density by one level according to the level sequence. The screen density levels are 300 dpi, 360 dpi, 420 dpi and 480 dpi, and the current level is 300 dpi. The first density is set to 360 dpi by increasing one level.
[0143] After executing S606, the electronic device may restart the first application, that is, re-execute the processes of S601 and S602. The result of S602 is that the screen density does not need to be readjusted, and S607 and S608 are directly executed.
[0144] After executing S606, the electronic device may also set the adjustment flag of the first application to the first flag, or add the first application to the application registration list.
[0145] Optionally, the electronic device may not execute S602 and the process of setting the adjustment flag of the first application to the first flag in S606. Or the process of adding the first application to the application registration list may be directly executed in S603 after executing S601, thereby reducing the judgment process and improving processing efficiency.
[0146] S607: The electronic device draws a view of the first application based on the first density and the first ViewTree.
[0147] Among them, before S607, the electronic device can determine the first density of the current first application. Specifically, the electronic device can determine the first density based on the value of the stored first density. In executing S602, when the result is that it is not necessary to determine whether to adjust the screen density of the first application, in the application whitelist, the electronic device determines that the density of the application that has been adjusted is the first density; the density of the application that has not been adjusted is the first density. Specifically, after executing S605, the electronic device can determine that the default density of the first application is the first density.
[0148] After determining the first density of the first application, the electronic device may draw a view of the first window of the first application based on the first density and the first ViewTree.
[0149] S608: The electronic device displays the user interface of the first application.
[0150] After the drawing is completed in S607, the electronic device displays the user interface of the first application.
[0151] Figure 6 In the implementation manner, the screen in the user interface of the first application displayed by the electronic device is not blocked or occupied, that is, the electronic device can display the complete screen. For example, Figure 7 Schematic diagram of a user interface disclosed in an exemplary embodiment of the present application. Figure 7 As shown, the electronic device can display the user interface of the smart home appliance application. Figure 7 and Figure 5B The difference is that the picture of the "TV in the second bedroom" and the display objects of the "speakers in the living room" will not be blocked, and the entire picture can be displayed completely to ensure user experience.
[0152] Figure 7 For Figure 5B The comparison results show that, in addition, Figure 6 In the embodiment, Figure 5D and Fig. 5F In the comparison results, there is no partial occlusion of the displayed object, and the user can clearly and completely see all the contents of the entire user screen. The display effect is the same as Figure 7 In addition, the above embodiments of the present application Figure 7 This is only the result of one scenario and may also include other scenarios and interface types, which are not limited in this application.
[0153] Figure 6 In an implementation manner, after the density is adjusted, the electronic device can display the user interface according to the adjusted density. The density is adjusted to be larger, and the overall size of the components in the interface becomes smaller. A higher screen density means that more pixels can be accommodated under the same screen size, thereby ensuring that all sub-views of the image can be displayed completely, thereby improving the user experience.
[0154] Combined with the user's operation of launching the application and Figure 6 The specific processing process of each module in the electronic device is further described in detail below. Figure 8 The embodiments are described in detail below.
[0155] Figure 81 is a flow chart of a method for displaying an interface disclosed in an exemplary embodiment of the present application. Figure 8 As shown, the method for displaying an interface may include the following steps:
[0156] The electronic device may include a desktop application, a first application, an activity management service AMS, a window management service WMS and a view system. For details, please refer to Figure 2 It should be noted that the execution process of the above modules is only an exemplary description, and the electronic device may include more or fewer modules to implement Figure 8 The present application does not specifically limit this method.
[0157] S801: When the user performs a first operation, the desktop application obtains a first input event, and the desktop application sends first operation information to the first application.
[0158] The first operation is an operation of starting the first application. For example, the electronic device displays a desktop interface, and the user clicks the icon of the first application in the desktop interface. In response to the first operation, the electronic device needs to display the user interface of the first application. The first operation can be specifically referred to as Figure 5A The operation of clicking the smart home (first application) icon in the description will not be repeated. In addition, the first operation may also be an operation of opening the first application from other applications. This application does not limit the launch scenario of the first operation on the first application. The operation mode of the first operation may be touch, voice, air gesture, etc. This application does not limit this. The first operation information may include the application package name of the first application, etc.
[0159] The first application is a complete application that has been installed on the electronic device. Before executing the first operation, the electronic device does not run the first application, that is, the life cycle of the first application is in an ended state. After executing the first operation, the electronic device can create the life cycle of the first application, and the life cycle of the first application is in an active state.
[0160] S802: In response to the first operation, the first application sends a create activity request to the AMS.
[0161] After receiving the first operation information, the first application starts to send a request to create an activity to the AMS in response to the first operation, and the first application can execute the startActivity() function. The startActivity() function is used to request to create an activity process of the first application.
[0162] Optionally, after the AMS receives the create activity request from the first application, the first application may send a create reply message, where the create reply message is used to reply to the create activity request.
[0163] S803: The AMS creates a first activity based on the create activity request.
[0164] After receiving the request to create an activity, the AMS may create a first activity based on the request to create an activity. The first activity is an activity process Activity of the first application. Specifically, the AMS may execute an onCreate() function to start creating the first activity.
[0165] S804: The AMS sends a window creation request to the WMS.
[0166] After the AMS creates the first activity, it can send a window creation request to the WMS. Specifically, the AMS can execute the create window AddWindow() function. AddWindow is used to create a new window of the first application.
[0167] S805: WMS sends a window re-layout request to the view system.
[0168] After executing the AddWindow() function to create a window, WMS can execute the relayoutWindow() function to re-layout the window, that is, WMS sends a request to the view system to re-layout the window.
[0169] S806: The view system sends a request to the WMS for obtaining screen size information.
[0170] After receiving the window re-layout request, the view system can execute the getBounds() function to request the screen size information.
[0171] After WMS obtains the screen size information acquisition request, it can obtain the current screen size information. The screen size information includes information that can represent the width and height of the screen. For example, the screen width W, the screen height H, and another example, two diagonal coordinate information (w1, h1), (w2, h2). Among them, the screen width W = w2-w1; the screen height H = h2-h1.
[0172] S807: WMS sends screen size information to the view system.
[0173] After the WMS obtains the first screen size information, it may send the screen size information to the view system. The view system may receive the screen size information from the WMS.
[0174] S808: The view system determines window information based on the screen size information.
[0175] After the view system receives the screen size information from the WMS, it can determine the window mode, and then determine the window information based on the screen size information and the window mode.
[0176] For the description of S808, reference may be made to the process of obtaining window information based on the window mode and screen size in S601, which will not be described in detail.
[0177] S809: The view system determines whether the adjustment flag of the first application is true. If the adjustment flag is true, execute S810; if the adjustment flag is false, execute S812.
[0178] The processing process of S809 may refer to the relevant description in S602 and will not be described in detail.
[0179] The electronic device may store an adjustment mark bit of an application, and the application whitelist in S602 may include 0 to multiple applications, with no limit on the number. When the package name of the first application is included in the application whitelist, the adjustment mark bit of the first application = true, i.e., the first mark; when the package name of the first application is not included in the application whitelist, the adjustment mark bit of the first application = false (second mark) or no mark. Optionally, after the first application is installed, the adjustment mark bit of the first application may be set to false.
[0180] If the electronic device determines that the adjustment flag bit = true, it is determined that the current density of the first application can solve the problem of screen crowding and occlusion (the judgment has been made before, and there is no need to execute S812 again), and directly executes S810, S811 and S815. In the case of the adjustment flag bit = false, it is impossible to determine whether the current density of the first application can solve the problem of screen crowding and occlusion, and it is necessary to execute S812.
[0181] Among them, the electronic device establishes an application whitelist and sets the adjustment mark of the application, which can reduce the number of judgments. Before an application is updated, the same density can be used to solve the problem of incomplete screen display. There is no need to traverse and compare the view wall every time it is started, which reduces the waste of processing resources and improves execution efficiency.
[0182] S810: The view system obtains a first density of a first application.
[0183] When the first application adjustment flag is true, the view system obtains the first density of the first application.
[0184] Among them, the application whitelist includes two types of applications, one is the application that has been adjusted, and the other is the application that is not adjusted. In the application whitelist, the application name and screen density of each application are stored corresponding to the adjusted application; the application that is not adjusted is stored corresponding to the application name. When the first application is an adjusted application, the screen density corresponding to the first application is determined to be the first density; when the first application is an unadjusted application, the default density of the first application can be determined as the first density. For a specific description, please refer to the relevant description in S602, which will not be repeated here.
[0185] S811: The view system sends a first configuration change notification to the AMS.
[0186] After the view system obtains the first density of the first application, the view system executes the configuration change onCongfigChange() function, that is, sends a first configuration change notification to the AMS. After the AMS receives the first configuration change notification, it executes S815.
[0187] S812: The view system traverses the subviews to determine whether the first subview area exceeds the first parent view area. If so, execute S813; if not, execute S817.
[0188] The processing process of S812 may refer to the processing process of S603 to S605, and will not be described in detail.
[0189] Among them, the judgment process of S812 can ensure that the area of the parent node displayed in the view tree can include the area of the child node, ensure that there is no obstruction in the display screen, and fully display the entire interface.
[0190] Optionally, the view system, while executing the process of traversing the subviews, also executes the process of determining whether the areas of different views in the same ViewGroup overlap. In the case of overlap, S813 is also executed; in the case of overlap, S817 is executed. Assume that in the first viewtree, the ViewGroup includes viewA and viewB, and the first coordinate interval of the X-axis in the two coordinate information of viewA and the second coordinate interval of the X-axis in the two coordinate information of the viewB range do not intersect, that is, they do not overlap. If there is an intersection, it is an overlap. Similarly, it can be determined by the coordinate information of the Y axis, which will not be repeated. Exemplarily, the first coordinate information of viewA is the X-axis coordinate x1, and the second coordinate information of viewA is the X-axis coordinate x2; the first coordinate information of viewB is the X-axis coordinate x3, and the second coordinate information of viewB is the X-axis coordinate x4. When x3 and x4 are both outside the interval from x1 to x2 (including the point values from x1 to x2), there is no overlap; otherwise, it is determined to be overlapping.
[0191] The first coordinate information and the second coordinate information are the two diagonal coordinates of the two rectangular areas of the view.
[0192] S813: The view system sets the first density of the first application, and sets the adjustment flag of the first application to true.
[0193] The view system can set the screen density of the first applicable window to a different density value than the previous one.
[0194] The process of setting the first density of the first application by the view system may refer to the relevant content in S606 and will not be described in detail.
[0195] After the view system sets the first density of the first application, the adjustment flag of the first application can be set to true. Optionally, the electronic device can store the package name of the first application and the corresponding first density in the application whitelist. After determining the new density of the first application, the result should be stored to avoid executing S812 and S813 again, reduce the number of processing times, improve execution efficiency, and save processing resources.
[0196] S814: The view system sends a second configuration change notification to the AMS.
[0197] After the view system sets the first density of the first application, the view system may also execute the configuration change onCongfigChange() function. For details, please refer to the content of S811 and will not be repeated here.
[0198] S815: The AMS restarts the first application.
[0199] After the AMS receives the second configuration change notification in S814, it may restart the first application, that is, execute the Relanuch() function. The Relanuch() function is used to request to restart the active process of the first application.
[0200] After AMS restarts the first application, the electronic device can reconfigure the screen density and adjust the screen density to the first density after setting.
[0201] S816: The AMS sends an application drawing request to the view system.
[0202] After restarting the first application or receiving the first configuration change notification, the AMS may send an application drawing request to the view system, that is, requesting to draw the view of the first application.
[0203] S817: The view system draws the view of the first application.
[0204] After receiving the application window drawing request from AMS in S816 or determining in S812 to traverse the sub-views and determining that the first sub-view area does not exceed the first parent view area, the view system can draw the view of the first application, that is, execute the onDraw() function.
[0205] S818: The view system sends a display request to SurfaceFlinger.
[0206] After the view system draws the view of the first application, it can send a display request to SurfaceFlinger. The display request can request to display the window layer of the first application.
[0207] S819: SurfaceFlinger renders and synthesizes the layers of the first application and displays the first user interface.
[0208] After receiving the display request, SurfaceFlinger can render and synthesize the layers of the first application and display the first user interface, that is, display the first window.
[0209] The first user interface is the user interface displayed after the first application is started. For details, please refer to Figure 7 Related content in .
[0210] Above Figure 8In the implementation method, the electronic device avoids the problem of screen display obstruction and crowding caused by incompatible processing by the application manufacturer, ensures the integrity of the display, and improves the user experience. Furthermore, when it is determined that the screen can be fully displayed, the screen density is not adjusted (the screen density determined last time is inherited), and the screen is kept as close to the original layout of the application interface as possible, reducing the processing process and improving the execution efficiency.
[0211] Combination Figure 6 and Figure 8 implementation method, Fig. 9A and Fig. 9B It is a process diagram of a group of display interface methods provided in an embodiment of the present application. Fig. 9A and Fig. 9B There are two situations: one where the screen density needs to be adjusted and the other where the screen density does not need to be adjusted.
[0212] Fig. 9A In the case where the screen density needs to be adjusted. In response to the user's first operation, the electronic device starts the first application and can traverse the views in the first window of the first application (the first window is not displayed at this time, and there are display objects blocked in the first window). In the case where the size of a subview in the first window is larger than the size of the parent view, the electronic device adjusts the screen density from the first value to the second value. After that, the first window (the window of the first application) is displayed according to the screen density of the second value. The screen in the first window is completely displayed, and there is no blocking or crowding of display objects, that is, the size of the subview in the first window is smaller than the size of the parent view.
[0213] Fig. 9B In the case where the screen density does not need to be adjusted. In response to the user's first operation, the electronic device starts the first application and can traverse the views in the first window of the first application (the first window is not displayed at this time, and no part of the screen is blocked in the first window). In the case where there is no child view larger than the parent view in the first window, the electronic device keeps the screen density unchanged at the first value, that is, does not process the screen density, and then still displays the first window according to the screen density of the first value. The screen in the first window is displayed completely without any blocking or crowding of the screen.
[0214] The above two situations are aimed at determining whether to adjust the screen density based on different judgment results. First, it is ensured that the picture is not blocked and displayed completely to ensure the user's operation and reading experience.
[0215] As used in the above embodiments, the term "when..." may be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...", depending on the context. Similarly, the phrases "upon determining..." or "if (the stated condition or event) is detected" may be interpreted to mean "if determining..." or "in response to determining..." or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)", depending on the context.
[0216] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc.
[0217] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
Claims
1. A method for displaying an interface, characterized in that: The method is applied to an electronic device, and the method comprises: The electronic device displays a first user interface, where the first user interface is a desktop interface; In response to a first operation on the first user interface, the electronic device creates a first window; the first operation is an operation of starting a first application; the first window is a window of the user interface of the first application; the screen density of the first window is a first value; The electronic device obtains window information of the first window, and when traversing the first viewtree and determining based on the window information that an area of the first view in the first viewtree exceeds an area of the second view, the electronic device sets the screen density of the first window to a second value; the first window includes the first view and the second view, the first view is a subview of the second view; the second value is greater than the first value; the first viewtree is used to describe a view structure of the first window; The electronic device displays the first window based on the second value.
2. The method according to claim 1, characterized in that The method further comprises: In response to a second operation on the first user interface, the electronic device creates a second window; the second operation is an operation of starting a second application; the screen density of the second window is a third value; The electronic device obtains window information of the second window, and when traversing the second viewtree and determining based on the window information that an area in the second viewtree where the third view does not exist exceeds an area of the fourth view, the electronic device displays the second window based on the third value, and the screen density of the second window remains at the third value; the second window includes the third view and the fourth view, and the third view is a subview of the fourth view; the second viewtree is used to describe the view structure of the second window.
3. The method according to claim 1, characterized in that The method further comprises: The electronic device traverses the first viewtree, and determines, based on the window information, whether an area of a child view in the first viewtree exceeds an area of a parent view.
4. The method according to claim 1, characterized in that: After the electronic device acquires the window information of the first window, the method further includes: When the adjustment mark of the first application is not the first mark, the electronic device traverses the first viewtree and determines, based on the window information, whether an area of a child view in the first viewtree exceeds an area of a parent view.
5. The method according to claim 4, characterized in that When the adjustment flag of the first application is the first flag, the electronic device determines not to set the screen density of the first application.
6. The method according to claim 4, characterized in that After the electronic device sets the screen density of the first window to a second value, the method further includes: The electronic device sets the adjustment flag of the first application to the first flag, and stores the screen density of the first application as the second value.
7. The method according to claim 4, characterized in that After the electronic device determines, based on the window information, whether an area of a child view in the first viewtree exceeds an area of a parent view, the method further includes: The electronic device sets the adjustment flag bit of the first application to the first flag.
8. The method according to claim 5 or 7, characterized in that: After the electronic device sets the screen density of the first window to a second value, the method further includes: The electronic device restarts the first application, and determines whether the adjustment mark of the first application is the first mark; When the adjustment mark of the first application is the first mark, the screen density of the first window displayed by the electronic device is the second value.
9. The method according to any one of claims 1 to 7, characterized in that: The subview in the first viewtree of the first window is any view in the first viewtree; When the first view is the root view of the first viewtree, the second view is the first window.
10. The method according to claim 3 or 4, characterized in that: The electronic device acquires window information of the first window, including: The electronic device determines a window mode and a display scene of the first window; the window mode includes one of full screen, split screen, floating window and parallel horizon, and the display scene represents a display direction and a display screen of the electronic device; The electronic device determines window information based on the screen size, the window mode and the display scenario, where the window information indicates the size and position of the first window display.
11. An electronic device, characterized in that: include: One or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program codes, the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method as described in any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
