Application interface layout method and electronic device
The application interface layout method with adaptive capabilities addresses the challenge of varying device specifications by using a single layout file to adjust views, reducing development and maintenance costs and optimizing storage and download efficiency.
Patent Information
- Application Number
- JP2023519551
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-06-21
- Filing Date
- 2021-09-15
- Publication Date
- 2024-11-20
- Estimated Expiration
- 2041-09-15
AI Technical Summary
Developers face a high workload in designing and maintaining different layout files for various display specifications of electronic devices, leading to increased development and maintenance costs, as well as larger application installation packages due to the inclusion of multiple layout files.
An application interface layout method that uses a single layout file with adaptive capabilities, such as expansion, ratio, equalization, concealment, and stretching, to adjust the size and position of child views based on device parameters, allowing electronic devices with different specifications to display consistent interfaces.
Reduces development and maintenance workload by enabling a single layout file to adapt to diverse device specifications, optimizing storage space and download speed while maintaining consistent display quality across different electronic devices.
Smart Images

Figure 0007587691000011 
Figure 0007587691000012 
Figure 0007587691000013
Abstract
Description
[Technical field]
[0001] This application is incorporated herein by reference in its entirety, as well as Chinese Patent Application No. 202011058008.5, filed on September 29, 2020 with the State Intellectual Property Office of the People's Republic of China and entitled "APPLICATION INTERFACE LAYOUT METHOD AND ELECTRONIC DEVICE", Chinese Patent Application No. 202011110788.3, filed on October 16, 2020 with the State Intellectual Property Office of the People's Republic of China and entitled "APPLICATION INTERFACE LAYOUT METHOD AND ELECTRONIC DEVICE", Chinese Patent Application No. 202011142738.3, filed on October 22, 2020 with the State Intellectual Property Office of the People's Republic of China and entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL", Chinese Patent Application No. 202011142738.3, filed on October 22, 2020 with the State Intellectual Property Office of the People's Republic of China and entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL", Chinese Patent Application No. 202011142649.9 entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL" filed on October 22, 2020 with the State Intellectual Property Office of the People's Republic of China; Chinese Patent Application No. 202011141053.7 entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL" filed on October 29, 2020 with the State Intellectual Property Office of the People's Republic of China; Chinese Patent Application No. 202011183319.4 entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL" filed on October 29, 2020 with the State Intellectual Property Office of the People's Republic of China; Chinese Patent Application No. 202011183328.3 entitled "APPLICATION INTERFACE LAYOUT METHOD AND TERMINAL" filed on October 30, 2020 with the State Intellectual Property Office of the People's Republic of China; TERMINAL” under Chinese patent application No. 202011189853.6, and claims priority to Chinese Patent Application No. 202110687153.8, entitled “APPLICATION INTERFACE LAYOUT METHOD AND ELECTRONIC DEVICE,” filed with the State Intellectual Property Office of the People's Republic of China on June 21, 2021.
[0002] The present application relates to the field of electronic technology, and in particular to an application interface layout method and electronic device. [Background technology]
[0003] Electronic devices are N By using the layout file, a user can be provided with various application functions. In general, when developing an application, a developer designs the layout of a view or a view group on each display interface of the application to form a layout file, and packs the layout file into an installation package of the application. When an electronic device installs and runs the application, the corresponding layout file is called and the corresponding display interface is presented on the display. Currently, the number of categories of electronic devices is increasing, and displays with various specifications (e.g., dimensions) have appeared. If a developer needs to design and develop different layout files for displays of all specifications, the development and maintenance workload is large. Summary of the Invention [Means for solving the problem]
[0004] The present application provides an application interface layout method and electronic device for reducing an application developer's workload in developing and maintaining application interface layout files.
[0005] To achieve the aforementioned objectives, the embodiments of the present application provide the following technical solutions:
[0006] According to a first aspect, an application interface layout method is provided. An electronic device installs an application installation package of a first application, the application installation package including a first layout file, the first layout file indicating N child views and enabled preset capabilities, where N is a positive integer. The preset capabilities include one or more of an expansion capability, a proportion capability, an equalization capability, a stretch capability, and a hiding capability. The method includes the electronic device receiving a first operation performed by a user on a first interface. In response to the received first operation, the electronic device determines attribute values of the N child views based on device parameters of the electronic device and the preset capabilities, the device parameters of the electronic device including at least one of a screen type value, a screen dimension value, or a running state value of the electronic device, and the attribute values of the N child views are used to indicate sizes and positions of the N child views on a second interface. The electronic device displays the N child views on the second interface based on the attribute values of the N child views.
[0007] The screen type includes any one of a bezel-less screen, a curved screen, a notch screen, a drop screen, a folding screen, etc. It is easy to understand that the screen type affects the overall display size and display position of the first application on the screen, and further affects the display of the child view in the first layout container. The running state includes one or more of a landscape / portrait state, a split screen state, and a folded state of the electronic device. It is easy to understand that different running states of the electronic device indicate different display sizes and display positions of the first application on the screen, so as to restrict the display of the child view in the first layout container.
[0008] It can be found that the attribute values of the N child views in the first layout file are not fixed, but are related to device parameters of the electronic device. The device parameters include at least one of the screen type, screen dimension, or running state of the device. In other words, when the electronic device parameters are different, the electronic device adaptively changes the size and / or position of the N child views based on the device parameters and preset capabilities of the electronic device. It can be further found that the present solution can enable electronic devices with different device parameters to present different display effects based on the same layout file, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0009] In addition, compared with the solution in which the application installation package needs to carry multiple layout files, the solution in which the application installation package carries one layout file increases the traffic cost and time cost of downloading the application installation package by the electronic device. In addition, after installing the application, the electronic device does not need to store another redundant layout file, which improves the storage space utilization rate of the electronic device.
[0010] It should be further noted that the aforementioned preset capabilities (i.e., adaptive layout capabilities) may be used independently or in combination with each other. For example, different adaptive layout capability attributes are set for different objects (View or ViewGroup) on the same application interface, or two or more adaptive layout capability attributes are set for the same object. It can be understood that in the actual application development process, in addition to the case where a contradiction occurs during the combination, the aforementioned adaptive layout capabilities may be randomly combined according to the actual requirements. For example, the stretch capability may be combined with any one of the hiding capability, the proportion capability, the equalization capability, and the wrapping capability, and the scaling capability may be combined with any one of the hiding capability, the proportion capability, the equalization capability, and the wrapping capability.
[0011] In a possible implementation, the first layout file includes preset parameters corresponding to the preset capabilities. The electronic device determining attribute values of the N child views based on the device parameters and the preset capabilities of the electronic device includes the electronic device determining attribute values of the N child views based on the device parameters, the preset capabilities, and the preset parameters of the electronic device.
[0012] In a possible implementation, the execution states of the electronic device include one or more of a landscape / portrait state, a split screen state, and a folded state of the electronic device.
[0013] In a possible implementation, the first operation is one of an operation to launch a first application, an operation to jump to a second interface, or an operation to switch an execution state of the electronic device.
[0014] For example, if the second interface is the home page of the first application, the first operation is an operation of launching the first application, or if the second interface is not the home page of the first application, the first operation is an operation of instructing a jump from the first interface to the second interface. In another scenario, when the electronic device displays the interface of the first application, if it is detected that the user has switched the running state of the electronic device, for example, switched from a portrait state to a landscape state, switched from an unfolded state to a folded state, or switched from a non-split-screen state to a split-screen state, the electronic device reacquires device parameters of the device, recalculates attribute values of the N child views based on the updated device parameters and preset capabilities of the device, and refreshes the current interface. In other words, the same functional interface of the first application has different layouts in different operating states of the electronic device, i.e., the layouts of the N child views on the second interface and the first interface are different.
[0015] In a possible implementation, the preset capability is an expanded capability, and the first layout file indicates that the N child views are arranged in a first orientation in a first layout container, the first orientation being a horizontal orientation or a vertical orientation. Determining attribute values of the N child views by the electronic device based on device parameters and the preset capability of the electronic device includes the electronic device determining dimensions of the first layout container in the first orientation based on the device parameters, and determining N1 child views and an (N1+1)th child view of the N child views based on the dimensions of the first layout container in the first orientation and the dimensions of the N child views in the first orientation, where N1 is less than N. Displaying the N child views on the second interface by the electronic device based on the attribute values of the N child views includes the electronic device fully displaying the N1 child views and partially displaying the (N1+1)th child view on the second interface based on the attribute values of the N child views.
[0016] In other words, when the width of the layout container changes, the number of child views to be displayed may be automatically determined based on the dimensions of the layout container to meet the display requirements of electronic devices with different screen dimensions. In addition, in the present application, based on the change of the layout container, the number of child views to be displayed may be adaptively reduced, and child views that display only partial content may also be displayed. The dimensions of the partial content displayed by the child views may be maintained at a fixed value (i.e., a dimension threshold). In this way, child views that display only partial content may be used to prompt the user that there are still child views that are not displayed in the layout container. In addition, by maintaining the dimension threshold as a fixed value, the user may not feel irregular confusion due to different screen dimensions resulting in different dimensions of child views that display partial content.
[0017] In a possible implementation, the preset parameters of the expansion capability include a first dimension and a first spacing. The electronic device determining attribute values of the N child views based on the device parameters and the preset capabilities of the electronic device includes determining that the N1 child views are displayed in the first layout container based on the dimensions of the first layout container in the first orientation, the dimensions of the N child views in the first orientation, the first dimension, and the first spacing, and determining partial content to be displayed by the (N1+1)th child view. The electronic device displaying the N child views on the second interface based on the attribute values of the N child views includes the electronic device displaying the N1 child views and partial content of the (N1+1)th child view on the second interface, where the spacing between two adjacent child views is equal to or greater than the first spacing.
[0018] The first spacing is the spacing threshold. The first dimension is the display dimension of the (N1+1)th child view. In this way, a developer may set the spacing between the first child views in the first layout container to avoid excessive crowding or content overlap of the first child views.
[0019] In a possible implementation, the preset parameters of the expansion capability further include a second interval, and the second interval is greater than the first interval. Prior to the steps of determining that N1 child views are displayed in the first layout container based on the dimensions of the first layout container in the first orientation, the dimensions of the N child views in the first orientation, the first dimensions, and the first interval, and determining partial content to be displayed by the (N1+1)th child view, the method further includes the steps of determining that the first layout container cannot display all of the N child views based on the dimensions of the first layout container in the first orientation, the dimensions of the N child views in the first orientation, and the second interval, reducing the interval between two adjacent child views, maintaining the interval between the two adjacent child views equal to or greater than the first interval, and determining that the first layout container cannot display all of the N child views in the process of reducing the interval between the two adjacent child views.
[0020] It may be noted that a developer may set a default spacing between the first child views. If the dimensions of the first layout container are insufficient to display all the first child views, the spacing between the first child views may be further narrowed to attempt to display all the first child views. If the spacing between the first child views is narrowed but not all the first child views can be displayed, ,child The view Incomplete It may be displayed.
[0021] In a possible implementation, the steps of determining, based on a dimension of the first layout container in a first orientation, the dimensions of the N child views in the first orientation, a first dimension, and a first spacing, that N1 child views are to be displayed in the first layout container; and determining partial content to be displayed by an (N1+1)th child view, based on a dimension of the first layout container in a first orientation, the dimensions of the N child views in the first orientation, a second spacing, and the first dimension, that N2 child views are to be displayed in the first layout container, where a spacing between two adjacent child views of the N2 child views is a third spacing, and the N2 the third spacing is greater than or equal to N1 and less than N, and if the third spacing is less than the first spacing, the value of N2 is decreased by 1; adjusting the third spacing based on a dimension of the first layout container in the first orientation, dimensions of the N2 child views in the first orientation, and the first dimension; if the adjusted third spacing is greater than or equal to the first spacing, determining that N1 child views will be displayed in the first layout container; determining partial content to be displayed by the (N1+1)th child view; and determining that a spacing between two adjacent child views is a fourth spacing, where N1=N2 and a difference between the fourth spacing and the adjusted third spacing is within 1 pixel.
[0022] In other words, if the first layout container cannot display all the first child views, the number N2 of the first child views that can be fully displayed is first determined based on the default interval, the dimensions of the first layout container, and the dimensions of the first child views, and then the third interval between two adjacent first child views is adjusted. If the third interval does not meet the interval threshold, the value of N2 is decreased by 1, and the third interval is adjusted again. This operation is repeated until the third interval can meet the interval threshold. In this case, the adjusted N2 is determined to be the number of first child views that can be fully displayed in the first layout container, and the interval between the first child views is determined.
[0023] In addition, since electronic devices perform display in units of pixels, the remaining space (such as the dimension of the first layout container minus the inner margin, the sum of the dimensions of the first child views, etc.) cannot be allocated strictly evenly, that is, the third interval may not be an integer. Therefore, the interval between the child views can be further fine-tuned so that the interval between the child views completely occupies the remaining space. The difference between the fine-tuned interval and the third interval is within 1 pixel. For specific fine-tuning methods, please refer to the related contents of this specification.
[0024] In a possible implementation, the method further includes the steps of receiving a second operation performed by a user on the second interface, and displaying a third interface in response to the second operation, the third interface displaying the (N1+2)th child view.
[0025] Because not all first child views in the first layout container are displayed in the second interface, by performing the second operation, a first child view that is not displayed in the second interface, for example, the (N1+2)th first child view, may be viewed.
[0026] In a possible implementation, the preset capability is a percentage capability, the first layout file indicates that the N child views are arranged in a first orientation of the first layout container, the first orientation being a horizontal orientation or a vertical orientation, and the preset parameters corresponding to the percentage capability include a percentage of the first child view within the N child views. The electronic device determining attribute values of the N child views based on the device parameters and the preset capability of the electronic device includes the electronic device determining dimensions of the first layout container in the first orientation based on the device parameters, and determining dimensions of the first child view in the first orientation based on the dimensions of the first layout container in the first orientation and the percentage of the first child view. The electronic device displaying the N child views on the second interface based on the attribute values of the N child views includes the electronic device displaying the first child view on the second interface. The first orientation may be a layout orientation of the first layout container or may be an orientation specified by a user.
[0027] In other words, when the electronic device runs the application, the electronic device obtains the device parameters, determines the display dimensions and display position of the application based on the device parameters, and further determines the dimensions of the first layout container, etc. Then, the electronic device calculates the dimensions of the child view based on the specified child view proportion and the dimensions of the first layout container, so as to meet the display requirements of electronic devices with different screen parameters. ratio It can be seen that the capability can enable electronic devices with different screen specifications to present different display effects based on the same layout settings, reducing the development and maintenance workload of developers and meeting the display requirements of various types of electronic devices.
[0028] In a possible implementation, the preset parameters corresponding to the proportion capabilities further include a proportion of the second child view among the N child views. The electronic device determining attribute values of the N child views based on the device parameters and the preset capabilities of the electronic device further includes determining dimensions of the second child view in the first orientation based on dimensions of the first layout container in the first orientation and a proportion of the second child view, the proportion of the second child view being the same as or different from the proportion of the first child view. The electronic device displaying the N child views on the second interface based on the attribute values of the N child views further includes the electronic device further displaying the second child view on the second interface based on the attribute values of the N child views.
[0029] In other words, different child views in the first layout container may have different proportions to meet different display requirements.
[0030] In a possible implementation, the preset parameters corresponding to the percentage capability further include a case where a percentage is not set for a third child view of the N child views or a case where the preset parameters corresponding to the percentage capability do not include a percentage for the third child view. Determining attribute values of the N child views by the electronic device based on the device parameters and the preset capabilities of the electronic device further includes determining a remaining space of a first layout container in a first orientation, where the remaining space of the first layout container in the first orientation is determined based on dimensions of the first layout container in the first orientation, an inner margin of the first layout container in the first orientation, and dimensions of child views included in the first layout container and for which percentages are set, and determining dimensions of a third child view in the first orientation based on the remaining space of the first layout container in the first orientation. Displaying the N child views on the second interface by the electronic device based on the attribute values of the N child views further includes the electronic device further displaying a third child view on the second interface based on the attribute values of the N child views.
[0031] It can be seen that the first layout container may include percentage and non-percentage child views, the dimensions of the percentage child views may be determined first, and then the dimensions of the non-percentage child views are determined based on the remaining space of the first layout container.
[0032] In a possible implementation, the first child view is a layout container view, the first child view includes a fourth child view with a percentage set, the layout orientation of the first child view is a second orientation, and the second orientation is perpendicular to the first orientation. The electronic device determining attribute values of the N child views based on device parameters and preset capabilities of the electronic device further includes the electronic device determining dimensions of the first child view in the second orientation based on the device parameters, and determining dimensions of the fourth child view in the second orientation based on the dimensions of the first child view in the second orientation and a percentage of the fourth child view. The electronic device displaying the N child views on the second interface based on the attribute values of the N child views includes the electronic device displaying the fourth child view on the first child view.
[0033] In other words, the interface of a layout container with percentage capabilities enabled is nested within another layout container with percentage capabilities enabled.
[0034] In a particular implementation, a ratio capability may be set for a layout container in which a text view, a button view, an image view, etc. are located. When the width or height of the layout container changes, the width or height of the text view, the button view, or the image view may automatically and adaptively change based on the width or height of the layout container, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the ratio capability in the present solution can enable electronic devices with different screen parameters to present different display effects based on the same layout setting, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0035] In a possible implementation, the preset capabilities are equalization capabilities, and the first layout file indicates that the N child views are arranged in a first orientation in a first layout container and indicates dimensions of each of the N child views in the first orientation and an inner margin of the first layout container in the first orientation. Determining attribute values of the N child views based on device parameters of the electronic device and the preset capabilities includes the electronic device determining dimensions of the first layout container in the first orientation based on the device parameters, and determining a first spacing based on the dimensions of the first layout container in the first orientation, the dimensions of each of the N child views in the first orientation, and the inner margin of the first layout container in the first orientation, where the first spacing is a spacing between two adjacent child views, and the two adjacent child views have equal spacing. The electronic device displaying N child views on the second interface based on attribute values of the N child views includes the electronic device displaying N child views on the second interface based on attribute values of the N child views, where a spacing between two adjacent child views is a first spacing.
[0036] In other words, when the electronic device runs the application, the electronic device obtains the device parameters, determines the display dimensions and display position of the application based on the device parameters, and further determines the dimensions of the first layout container, etc. Then, the electronic device adaptively determines the spacing between adjacent child views based on the width / height of the first layout container, the inner margin of the first layout container, and the width / height of each child view in the first layout container. It can be found that the equalization ability in the present solution can enable electronic devices with different screen specifications to present different display effects based on the same layout settings, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0037] In a possible implementation, the preset parameters of the equalization capability include a spacing type corresponding to the first layout container, and the spacing type is a first type or a second type. After determining the first spacing, the method further includes determining a position of a first child view among the N child views based on the first orientation and the spacing type corresponding to the first layout container. If the first orientation is horizontal and the first layout container corresponds to a first type, the distance between the left edge of the first child view and the left edge of the first layout container is 0 or the left inner margin of the first layout container; if the first orientation is horizontal and the first layout container corresponds to a second type, the distance between the left edge of the first child view and the left edge of the first layout container is determined based on the left inner margin of the first layout container and the first spacing; if the first orientation is vertical and the first layout container corresponds to a first type, the distance between the top edge of the first child view and the top edge of the first layout container is 0 or the top inner margin of the first layout container; or if the first orientation is vertical and the first layout container corresponds to a second type, the distance between the top edge of the first child view and the top edge of the first layout container is determined based on the top inner margin of the first layout container and the first spacing.
[0038] It can be seen that two different types of equalization methods are defined. The first type of equalization method mentioned above means that no spacing needs to be allocated between the edge of the first child view that is closest to the layout container in the layout orientation and the edge of the last child view that is closest to the layout container in the layout orientation. The second type of equalization method mentioned above means that spacing needs to be allocated between the edge of the first child view that is closest to the layout container in the layout orientation and the edge of the last child view that is closest to the layout container in the layout orientation. This meets different spacing adjustment requirements of users.
[0039] In a possible implementation form, the preset parameters of the equalization capability further include a first threshold, and the step of determining the first interval includes the steps of: determining a dimension of the first space based on a dimension of the first layout container in the first orientation, a dimension of each of the N child views in the first orientation, and an inner margin of the first layout container in the first orientation; if the first layout container corresponds to a first type, evenly dividing the dimension of the first space into N-1 parts, where the dimension of each part is the second interval; or if the first layout container corresponds to a second type, evenly dividing the dimension of the first space into N+1 parts, where the dimension of each part is the second interval; if the second interval is greater than the first threshold, determining the first threshold as the first interval; or if the second interval is less than or equal to the first threshold, determining the second interval as the first interval.
[0040] It can be seen that the first threshold can be set to limit the range of adjusted spacing between child views such that the adjusted spacing is less than or equal to the first threshold.
[0041] In a possible implementation form, after the step of determining a position of a first child view among the N child views based on the first orientation and a spacing type corresponding to the first layout container, the method further includes a step of adjusting the position of the first child view in the first layout container with an alignment scheme of the N child views in the first layout container after the first threshold is determined as the first spacing, wherein the alignment scheme is one of horizontal center alignment, left alignment, right alignment, vertical center alignment, top alignment, and bottom alignment.
[0042] In a possible implementation form, the preset parameters of the equalization capability further include a second threshold, and the step of determining the first interval includes the steps of: determining a dimension of the first space based on a dimension of the first layout container in the first orientation, a dimension of each of the N child views in the first orientation, and an inner margin of the first layout container in the first orientation; if the first layout container corresponds to a first type, evenly dividing the dimension of the first space into N-1 parts, where each part has a dimension of the third interval; or if the first layout container corresponds to a second type, evenly dividing the dimension of the first space into N+1 parts, where each part has a dimension of the third interval; if the third interval is less than the second threshold, determining the second threshold as the first interval; or if the third interval is equal to or greater than the second threshold, determining the third interval as the first interval.
[0043] It can be seen that the second threshold can be further set to limit the range of the adjusted spacing between child views such that the adjusted spacing is greater than or equal to the second threshold.
[0044] In a possible implementation, the preset capability is a hiding capability, and the first layout file indicates that the N child views are arranged in a first orientation of a first layout container and indicates dimensions of each of the N child views in the first orientation and an inner margin of the first layout container in the first orientation. The electronic device determining attribute values of the N child views based on device parameters of the electronic device and the preset capabilities includes the electronic device determining dimensions of the first layout container in the first orientation based on the device parameters, and determining M child views from the N child views if the first dimension is greater than the second dimension, where M is an integer less than N, the first dimension is determined based on the dimensions of the N child views in the first orientation, and the second dimension is determined based on the dimensions of the first layout container in the first orientation and the inner margin of the first layout container in the first orientation. The electronic device displaying N child views on the second interface based on attribute values of the N child views includes the electronic device displaying M child views on the second interface based on attribute values of the N child views.
[0045] In other words, when the electronic device runs the application, the electronic device obtains the device parameters, determines the display dimensions and display position of the application based on the device parameters, and further determines the dimensions of the first layout container, etc. If the width or height of the layout container is insufficient to display all child views, some child views in the layout container may be automatically determined to be hidden, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the hiding ability in the present solution can enable electronic devices with different screen specifications to present different display effects based on the same layout settings, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0046] In a possible implementation, the sum of the dimensions of the M child views in the first orientation is less than or equal to the second dimension.
[0047] In the prior art, if an electronic device cannot display all the child views in the first layout container, the content exceeding the dimensions of the first layout container is simply truncated. As a result, some child views display only partial content, and the display interface is made irregular. However, in the solution provided in the present application, the M child views displayed in the first layout container are full content child views, i.e., all the content of the M child views is displayed, and the display interface is displayed neatly.
[0048] In a possible implementation, the step of determining M child views from the N child views when the first dimension is greater than the second dimension includes determining M child views from the N child views based on priorities of the N child views when the first dimension is greater than the second dimension.
[0049] In a possible implementation, the priority of each of the M child views is lower than the priority of the other N to M child views of the N child views.
[0050] In other words, the importance of child views within a first layout container may be set by setting the priority of the child views, thereby preventing child views located behind from simply being hidden or not displayed if the first layout container cannot display all of its child views.
[0051] In a possible implementation, the preset parameters of the hiding capability include where the N child views include at least one first child view, at least one second child view, and at least one third child view, where the priority of the first child view is higher than the priority of the second child view, and the priority of the second child view is higher than the priority of the third child view. The step of determining M child views from the N child views based on the priorities of the N child views when the first dimension is greater than the second dimension includes the steps of determining that the M child views do not include the first child view when the first dimension is greater than the second dimension; determining that the M child views include the second child view and the third child view when a sum of the dimensions of the second child view and the third child view in the first orientation is less than or equal to the second dimension; or determining that the M child views do not include the first child view and the second child view when a sum of the dimensions of the second child view and the third child view in the first orientation is greater than the second dimension; and determining that the M child views include the third child view when a sum of the dimensions of the third child view in the first orientation is less than or equal to the second dimension.
[0052] In other words, when the first layout container cannot display all of its child views, the child views to be hidden are determined in descending order of the hiding priority of the child views.
[0053] In a possible implementation, the preset parameters of the hiding capability further include a case where the N child views include at least one first child view, at least one second child view, and at least one third child view, and the priority of the first child view is higher than the priority of the second child view, and the priority of the second child view is higher than the priority of the third child view. The step of determining M child views based on the priorities of the N child views when the first dimension is greater than the second dimension includes a step of determining that the M child views include a third child view, and a step of determining that the M child views further include a second child view when a sum of the dimensions of the third child view and the second child view in the first orientation is less than or equal to the second dimension, or a step of determining that the M child views do not include the second child view and the first child view when a sum of the dimensions of the third child view and the second child view in the first orientation is greater than the second dimension.
[0054] In other words, when the first layout container cannot display all of its child views, the child views to be displayed are determined in order from lowest to highest hiding priority.
[0055] In a possible implementation form, after the step of determining M child views from the N child views, the method further includes a step of determining a spacing between adjacent child views in the M child views based on the second dimension and the sum of the dimensions of the M child views in the first orientation.
[0056] After the number of child views to be displayed in the layout container is determined, the spacing between adjacent child views is further adjusted so as to help the layout container present a better display effect.
[0057] In possible implementations, the spacing between adjacent child views in the M child views is equal or unequal.
[0058] In a possible implementation, the preset capability is a stretch capability, the first layout file indicates that the N child views are arranged in a second orientation of the first layout container, and the preset parameters corresponding to the stretch capability include a first threshold and / or a second threshold of the first layout container in the first orientation, the second orientation being different from the first orientation, and the second threshold being smaller than the first threshold. The electronic device determining attribute values of the N child views based on device parameters and preset capabilities of the electronic device includes the electronic device determining initial values of dimensions of the first layout container in the first orientation based on the device parameters, and determining that the dimensions of the first layout container in the first orientation are the first threshold if the initial value is greater than a first threshold, or determining that the dimensions of the first layout container in the first orientation are the second threshold if the initial value is less than a second threshold, and determining dimensions of a first child view within the first layout container in the first orientation based on the dimensions of the first layout container in the first orientation, the first child view being one of the N child views. The electronic device displaying the N child views on the second interface based on the attribute values of the N child views includes the electronic device displaying the first child view on the second interface based on the attribute values of the N child views.
[0059] When the electronic device executes the application, the electronic device obtains device parameters, determines display dimensions and a display position of the application based on the device parameters, and further determines initial values of dimensions of the first layout container in the first orientation based on dimensional constraints transferred by a parent layout container of the first layout container, or determines initial values of dimensions of the first layout container in the first orientation based on dimensions set in the layout file. The first threshold may be a maximum dimension value set in the layout file of the first layout container in the first orientation, and the second threshold may be a minimum dimension value set in the layout file of the first layout container in the first orientation.
[0060] It can be found that in the present application, after the initial value of the dimension of the first layout container in the first orientation is determined, the dimension of the first layout container in the first orientation may be adjusted by using a first threshold and a second threshold, so as to avoid excessive scaling up or down of the first layout container and further ensure that the first child view in the first layout container can present a better display effect. In other words, the present application provides a layout container whose dimension may be adaptively adjusted based on the device parameters of the electronic device, so that the view in the layout container may also be adaptively adjusted based on the device parameters of the electronic device. In this case, one layout file may be set for electronic devices with different device parameters, so that the developer does not design different layout files for electronic devices with different device parameters. In this way, the present application reduces the developer's workload in development and maintenance, and also meets the display requirements of various types of electronic devices.
[0061] It should be noted that a typical application installation package contains multiple types of files, such as logical code files, resource files, and layout files. Layout files are used to define the graphical user interface (GUI) (i.e., display interface), i.e., to define the hierarchical relationships between the views and layout containers on the display interface and attributes such as dimensions and positions. Logical code files are the execution logic behind the views and layout containers on the display interface. Resource files contain the content to be displayed in the views and layout containers on the display interface, e.g., images, videos, and websites.
[0062] In a possible implementation, a larger dimension of a first layout container in a first orientation indicates a larger dimension of a first child view in the first orientation.
[0063] In other words, on electronic devices having different device parameters, the dimensions of the first child view in the first orientation increase as the dimensions of the first layout container in the first orientation increase, so that the dimensions of the first child view can be adaptively adjusted on electronic devices having different device parameters. In this way, a developer may configure one layout file for electronic devices having different device parameters.
[0064] In a possible implementation, the step of determining dimensions of a first child view in a first layout container in a first orientation based on dimensions of the first layout container in the first orientation includes determining that the dimensions of the first child view in the first orientation are the same as the dimensions of the first layout container in the first orientation, or determining that the dimensions of the first child view in the first orientation are the dimensions of the first layout container in the first orientation minus an inner margin of the first layout container in the first orientation.
[0065] In one example, the dimensions of the first child view in the first orientation are the same as the dimensions of the first layout container in the first orientation, and the first layout container presents the first child view as large as possible in the first orientation to help the first child view display more content.
[0066] In another example, an inner margin of the first layout container may be further set. In this manner, by ensuring that a first child view in the first layout container is kept a certain distance from the edge of the first layout container, the display interface may present a magazine-like layout, e.g., present a large margin space, so that the display interface presents a magazine-like reading feel, thereby enhancing the user's visual experience.
[0067] In a possible implementation, the first orientation includes a horizontal orientation and / or a vertical orientation.
[0068] In other words, for a first layout container, a developer may set the stretch capability in one orientation or may set the stretch capability in two orientations. For example, if the stretch capability in horizontal orientation of the first layout container is set, the width of the first layout container changes with the width of the screen. If the stretch capability in vertical orientation of the first layout container is set, the height of the first layout container changes with the height of the screen. If the stretch capability in horizontal and vertical orientation of the first layout container is set, the width of the first layout container changes with the width of the screen and the height of the first layout container changes with the height of the screen.
[0069] In a possible implementation, if the first orientation is a horizontal orientation, the inner margin of the first layout container in the first orientation includes a left inner margin and / or a right inner margin, where the left inner margin is the distance from the left edge of the leftmost view in the layout container to the left edge of the layout container, and the right inner margin is the distance from the right edge of the rightmost view in the layout container to the right edge of the layout container. If the first orientation is a vertical orientation, the inner margin of the first layout container in the first orientation includes a top inner margin and / or a bottom inner margin, where the top inner margin is the distance from the top edge of the topmost view in the layout container to the top edge of the layout container, and the bottom inner margin is the distance from the bottom edge of the bottommost view in the layout container to the bottom edge of the layout container.
[0070] In a possible implementation, each of the N child views is one of a text view, an edit view, a button view, and an image button view.
[0071] According to a second aspect, there is provided an electronic device including a processor, a memory, and a touch screen, the memory, the touch screen, and the processor being coupled, the memory being configured to store computer program code, the computer program code including computer instructions, and the processor executing the computer instructions in the memory enables the electronic device to perform the method of the first aspect and any one of the possible implementations of the first aspect.
[0072] According to a third aspect, an apparatus is provided. The apparatus is included in an electronic device, and the apparatus has a function of implementing the behavior of the electronic device in the method according to the first aspect and any one of the possible implementations. The function may be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes at least one module or unit corresponding to the aforementioned function, such as a receiving module or unit, a display module or unit, and a processing module or unit.
[0073] According to a fourth aspect, there is provided a computer-readable storage medium comprising computer instructions which, when executed on an electronic device, enable the electronic device to perform a method according to the first aspect and any one of the possible implementations of the first aspect.
[0074] According to a fifth aspect, a graphical user interface on an electronic device is provided. The electronic device includes a display, a memory, and one or more processors. The one or more processors are configured to execute one or more computer programs stored in the memory, and the graphical user interface includes a graphical user interface that is displayed when the electronic device executes the method according to the first aspect and any one of the possible implementations of the first aspect.
[0075] According to a sixth aspect, there is provided a computer program product comprising computer instructions which, when executed on a computer, enable the computer to perform the method according to the first aspect and any one of the possible implementations of the first aspect.
[0076] According to a seventh aspect, there is provided a chip system including a processor, the processor executing instructions causing the processor to perform a method according to the first aspect and any one of the possible implementations of the first aspect.
[0077] It can be understood that the electronic device, apparatus, computer readable storage medium, computer program product, graphical user interface, and chip system provided in the above aspects are all applicable to the corresponding methods provided above. Therefore, for the beneficial effects that can be achieved by the electronic device, apparatus, computer readable storage medium, computer program product, graphical user interface, and chip system, please refer to the beneficial effects in the corresponding methods provided above. Details will not be described again in this specification. [Brief description of the drawings]
[0078] [Figure 1 (1)] FIG. 2 is a schematic diagram of a structure of a display interface according to an embodiment of the present application; [Figure 1 (2)] FIG. 2 is a schematic diagram of a structure of a display interface according to an embodiment of the present application; [Diagram 2] 1 is a schematic flowchart of an adaptive display interface layout method according to an embodiment of the present application. [Diagram 3] 4 is a schematic flowchart of another adaptive display interface layout method according to an embodiment of the present application. [Figure 4(1)] FIG. 2 is a schematic diagram of a development interface for layout files of several display interfaces according to an embodiment of the present application. [Figure 4 (2)] FIG. 2 is a schematic diagram of a development interface for layout files of several display interfaces according to an embodiment of the present application. [Diagram 5] FIG. 1 is a schematic diagram of a structure of an electronic device according to an embodiment of the present application. [Figure 6] FIG. 2 is a schematic diagram of a structure of another electronic device according to an embodiment of the present application. [Figure 7A] FIG. 13 is a schematic diagram of another display interface layout method according to an embodiment of the present application. [Figure 7B]FIG. 13 is a schematic diagram of another display interface layout method according to an embodiment of the present application. [Figure 8] 1A to 1C are display effect diagrams of a layout container with expandability in different scenarios according to an embodiment of the present application. [Figure 9] 11A-11C are display effect diagrams of another layout container with expandability in different scenarios according to an embodiment of the present application. [Figure 10A] 1 is a schematic flow chart of a measurement method in a view system according to an embodiment of the present application. [Figure 10B(1)] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with expandable capabilities according to one embodiment of the present application. [Figure 10B(2)] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with expandable capabilities according to one embodiment of the present application. [Figure 11] FIG. 1 is a schematic diagram of another adaptive application interface layout method according to an embodiment of the present application. [Figure 12] 11A-11C are display effect diagrams of a layout container with ratio capability in different scenarios according to an embodiment of the present application. [Figure 13] 11A-11C are display effect diagrams of another layout container with ratio capability in different scenarios according to an embodiment of the present application. [Figure 14] 11A-11C are display effect diagrams of another layout container with ratio capability in different scenarios according to an embodiment of the present application. [Figure 15A(1)] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 15A(2)] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 15B(1)] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with proportion capabilities according to one embodiment of the present application. [Figure 15B(2)]FIG. 13 is an effect diagram of different electronic devices displaying a layout container with proportion capabilities according to one embodiment of the present application. [Figure 16] FIG. 1 is a schematic diagram of another adaptive application interface layout method according to an embodiment of the present application. [Figure 17] 1A to 1C are display effect diagrams of a layout container with equalization capability in different scenarios according to an embodiment of the present application. [Figure 18] 11A-11C are display effect diagrams of another layout container with equalization capability in different scenarios according to an embodiment of the present application. [Figure 19] 11A-11C are display effect diagrams of another layout container with equalization capability in different scenarios according to an embodiment of the present application. [Figure 20] 11A-11C are display effect diagrams of another layout container with equalization capability in different scenarios according to an embodiment of the present application. [Figure 21A] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 21B(1)] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with equalization capabilities according to one embodiment of the present application. [Figure 21B(2)] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with equalization capabilities according to one embodiment of the present application. [Figure 22] FIG. 1 is a schematic diagram of another adaptive application interface layout method according to an embodiment of the present application. [Diagram 23] 1A to 1C are display effect diagrams of a layout container with hiding ability in different scenarios according to an embodiment of the present application. [Figure 24A] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 24B] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Diagram 25]FIG. 11 is an effect diagram of different electronic devices displaying a layout container with hiding capability according to one embodiment of the present application. [Figure 26] FIG. 1 is a schematic diagram of another adaptive application interface layout method according to an embodiment of the present application. [Figure 27] 11A-11C are display effect diagrams of a layout container with stretching capability in different scenarios according to an embodiment of the present application. [Figure 28] 11A-11C are display effect diagrams of another layout container with stretching capability in different scenarios according to an embodiment of the present application. [Figure 29] 11A-11C are display effect diagrams of another layout container with stretching capability in different scenarios according to an embodiment of the present application. [Figure 30A(1)] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 30A(2)] 1 is a schematic flow chart of another measurement method in a view system according to an embodiment of the present application. [Figure 30B] FIG. 13 is an effect diagram of different electronic devices displaying a layout container with stretch capability according to one embodiment of the present application. [Diagram 31] FIG. 13 is a display effect diagram of several layout containers with multiple adaptive layout capabilities in different scenarios according to one embodiment of the present application. [Figure 32(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 32(2)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 33(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 33(2)]11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 33(3)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Diagram 34] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 35(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Fig. 35(2)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 36(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 36(2)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 36(3)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 37(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 37(2)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 38(1)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 38(2)] 11A-11C are display effect diagrams of several other layout containers with multiple adaptive layout capabilities in different scenarios according to an embodiment of the present application. [Figure 39] FIG. 1 is a schematic diagram of the structure of a chip system according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0079] In the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B can represent A or B. In this specification, "and / or" only describes the association relationship between the associated objects and represents that three relationships may exist. For example, A and / or B can represent the following three cases: only A is present, both A and B are present, and only B is present. The following terms "first" and "second" are intended for explanatory purposes only and should not be understood as an indication or implication of relative importance or an implied indication of the quantity of the technical features shown. Thus, a feature qualified by "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, unless otherwise specified, "multiple" means more than one. In the embodiments of the present application, the words "example" or "for example" are used to represent giving an example, an illustration, or an explanation. In the embodiments of the present application, any embodiment or design scheme described as an "example" or "for example" should not be described as preferred or having more advantages over another embodiment or design scheme. Rather, the use of words such as "example" or "for example" is intended to present relative concepts in a particular manner.
[0080] The Android system is used as an illustrative example. An application defines a graphical user interface (GUI) (i.e., a display interface) by using a layout file. The layout file contains a view tree, which contains views and layout containers.
[0081] A view is an element presented on a GUI, and can provide a specific operation function to a user or can be used to display specific content. For example, a view may specifically include a text view such as a TextView view and an EditText view, or may include a button view such as a Button view and an ImageButton view, or may include an image view such as an ImageView view. This is not limited to the embodiment of the present application.
[0082] A layout container is configured to store the views and layout structure of another layout container. In other words, a layout container can contain one or more views and can have one or more nested layout containers.
[0083] The display interface of the Android system is used as an example for explanation. Generally, one display interface corresponds to one Activity, one Activity holds one Window object (e.g., PhoneWindow), and the Window is used to draw various views. As the most basic window system of the Android system, the PhoneWindow has a top-level View object DecorView (actually, one ViewGroup). DecorView is the root view (ViewRoot) of all Views and ViewGroups, and is also called the root node view. DecorView contains ContentView (actually, one ViewGroup). ContentView is a view customized by each application, that is, the display interface of the application. ContentView is also called content view. ContentView contains one or more Views and / or one or more ViewGroups. It should be noted that in the interface display process, the electronic device starts from the performTraversals() method of the root view and traverses the entire view tree from top to bottom, and each view is responsible for drawing its view, and the ViewGroup needs to further be responsible for showing its child Views to perform drawing operations. Optionally, the DecorView further includes a TitleView that may be used to customize navigation of the display interface.
[0084] FIG. 1(1) is a schematic diagram of an alarm clock interface 10. The alarm clock interface 10 corresponds to one DecorView. The DecorView includes View1 (text view), View2 (image view), and ViewGroup1. ViewGroup1 specifically includes ViewGroup2, ViewGroup3, and View7 (button view). ViewGroup2 includes View3 (text view) and View4 (button view). Similarly, ViewGroup3 includes View5 (text view) and View6 (button view). For the hierarchical structure relationship between each View and each ViewGroup on the alarm clock interface 10, please refer to the view tree shown in FIG. 1(2).
[0085] For example, a developer may create a layout file for each display interface. Le To generate it, you may design the Views or ViewGroups on each display interface in your application using a layout scheme such as a LinearLayout scheme, a TableLayout scheme, a RelativeLayout scheme, a FrameLayout scheme, an AbsoluteLayout scheme, or a GridLayout scheme.
[0086] In other words, a developer may set the hierarchical structure of each View and each ViewGroup on the display interface, as well as attribute values (e.g., dimensions (width and height) and position) in the layout file of each display interface. The layout files of these display interfaces are then packed into an application installation package, and the application installation package is released to the application market. The electronic device may then download the application installation package from the application market and install the application installation package. When the application runs on the electronic device, the electronic device may obtain the application's layout file, draw a corresponding display interface based on the layout file, and present the display interface to a user.
[0087] It should be noted that in one solution, the layout file of the display interface may determine the attribute values of the View and ViewGroup included in the display interface. Once the attribute values of each View and each ViewGroup on the display interface are set in the layout file, the dimensions and positions of the View or ViewGroup on the display interface remain unchanged. In other words, the developer has determined the appearance of each display interface presented to the user when developing the application. It can be understood that if electronic devices with different screen specifications use the layout file to draw the same display interface, or if the entire display interface is simply reduced or enlarged, the display effect is often reduced when the same display interface is reused because the screen specifications of electronic devices are currently different. At present, some application developers design different layout files for displays with different specifications and adapt the corresponding logic, causing huge development and maintenance workload. In addition, because a large number of layout files are packed into the installation package of the application, the installation package of the application becomes excessively large, which affects the download speed of the installation package by the electronic device and the space occupied by storing the installation file after installation.
[0088] In another technical solution, for an electronic device with a large screen dimension, the layout files of multiple small electronic devices can be directly reused. For example, the large screen dimension is a tablet computer, and the screen dimension of the tablet computer is 1280×800 pixels, and the small screen dimension is a mobile phone, and the screen dimension of the mobile phone is 720×1080 pixels. In this case, when the tablet computer displays an application interface, the tablet computer may simultaneously display two or more windows, and each window uses the layout file of one display interface corresponding to the mobile phone. In other words, the tablet computer displaying one display interface is equivalent to the mobile phone displaying two or more display interfaces simultaneously. For example, the screen of the tablet computer is evenly divided into two windows, and the size of each window may be 640×800 pixels. Each window is used to display one interface of the mobile phone. Obviously, the aspect ratio of one window on the tablet computer is 640:800 (i.e., 4:5), and the aspect ratio of the interface of the mobile phone is 720:1080 (i.e., 2:3).
[0089] It should be noted that even if the large electronic device can reuse the layout files of multiple small electronic devices in a multi-window management manner, the aspect ratio of each window on the large electronic device often does not match the aspect ratio of the small electronic device. As a result, directly reusing the layout files of the small electronic device cannot present a relatively good interface layout.
[0090] An embodiment of the present application provides a display interface layout method for developing one layout file for one display interface of an application. The layout file is applicable to various electronic devices with different screen specifications. This is because the electronic device may adaptively adjust the display interface layout based on the screen parameters of the electronic device when running the application. This improves the display effect of electronic devices with different screen specifications and reduces the development and maintenance costs of developers. The screen parameters include screen specification (dimension) parameters and screen state parameters (e.g., landscape / portrait state and folded state of a folding screen).
[0091] In addition, even if the same or similar type of electronic devices have different screen parameters, most of the usage scenarios (such as user interaction methods, function views, etc.) are similar. Therefore, the display interfaces presented to the user are usually similar. Therefore, designing one layout file for one application can meet the design intention of the application developer. However, electronic devices with different screen parameters will adaptively adjust the dimensions and / or positions of Views and ViewGroups in the layout file on the display interface based on the adaptive layout capabilities of Views and ViewGroups to weaken the display limitations of different electronic devices. This helps users switch between different electronic devices for display and meets the display requirements of users in different scenarios. For example, in a distributed display scenario, a user may need to select multiple layout files corresponding to different function modules on one display interface for display. Layout files may be sent to different electronic devices. As another example, based on a current application scenario (such as a driving scenario, a home scenario, a fitness scenario, etc.), a user may switch between different electronic devices to display a display interface.
[0092] For example, when designing a layout file of each display interface in an application, a developer of the application may set attribute values extended in this embodiment of the present application for Views and ViewGroups included in the display interface. These extended attribute values do not uniquely determine the dimensions and positions of the Views or ViewGroups, but rather restrict the relative relationship (e.g., relative size relationship or relative position relationship) between a View or ViewGroup and another View (or another ViewGroup) on the display interface. In other words, when a developer develops an application, the developer does not determine the appearance of each display interface presented to a user. Then, when drawing a display interface by using a layout file, the electronic device obtains the screen parameters of the electronic device, determines the display parameters of the display interface (e.g., the display position and display size of the display interface on the screen of the electronic device), and performs a layout such as the dimensions, position, etc. of each View and each ViewGroup on the display interface based on the hierarchical structure and extended attribute values of each View and each ViewGroup included in the display interface in the layout file, as well as the screen parameters of the electronic device. For example, when an application is executed, the electronic device determines the appearance of each display interface presented to a user based on the screen parameters of the electronic device. It can be understood that electronic devices having different screen parameters will render different display interfaces based on the same layout file.
[0093] In some other embodiments, the solution provided in this embodiment of the present application may also be used in combination with the solution of a large screen reusing the layout file of a small screen. For example, an electronic device with a large screen can reuse multiple layout files of a small electronic device in a multi-window management manner. The multiple layout files of the small electronic device herein correspond to different display interfaces. In other words, one display interface of the application herein still corresponds to one layout file.
[0094] Therefore, when displaying a display interface in each window, the electronic device with a large screen adaptively adjusts the dimensions, positions, etc. of each View and each ViewGroup on the display interface based on the layout file of the display interface corresponding to the window and the dimensions of the window. In other words, even if the aspect ratio of each window on the electronic device with a large screen does not match the aspect ratio of the electronic device with a small screen, according to the adaptive layout solution provided in this embodiment of the present application, the interface displayed in each window on the electronic device with a large screen can still present a relatively good display effect.
[0095] As shown in FIG. 2, in the development phase, the developer develops one layout file (the layout file includes View and ViewGroup provided with extended attribute values in this application) for each display interface of the application on the developer device (e.g., computer) by using related development tools, packs the layout file into an installation package of the application, and uploads the application installation package to the server (cloud). Then, all electronic devices with different screen parameters (e.g., electronic devices of different types, or electronic devices of the same type but different models) can download the application installation package from the server and run the application installation package. Each of these different electronic devices can be found to obtain the screen parameters of the electronic device and determine the display parameters of the display interface of the application (e.g., the display position and display size of the display interface of the application on the screen of the electronic device). Then, the View and ViewGroup on the display interface of the application are arranged with reference to the display parameters of the application and the layout file in the aforementioned application installation package, and the corresponding display interface is displayed. For example, a mobile phone Figure 2 The interface shown in Figure 21 is drawn, and the smart watch is Figure 2 Vision draws the interface shown in Figure 2 Render the interface 23 shown in FIG.
[0096] It should be noted that in this specification, a View or ViewGroup with extended attributes is also referred to as a View or ViewGroup with adaptive layout capability. In other words, in this embodiment of the present application, each View or each ViewGroup on the display interface has adaptive layout capability. The adaptive layout capability of a View or ViewGroup can be implemented by using a code module. The following describes the implementation process in detail by using scaling capability as an example.
[0097] The adaptive layout capabilities of a View or ViewGroup include, but are not limited to, a scaling capability, a stretch capability, an obscuring capability, a wrapping capability (which may also be referred to as an auto-branching capability), an equalization capability, a proportion capability, and an expansion capability. The adaptive layout capabilities of a View or ViewGroup are briefly described herein and in detail below.
[0098] Scaling capability means that a View or ViewGroup has the ability to adaptively scale down or up for horizontal and vertical orientations within a layout container. For example, a View or ViewGroup's proportion in a specified orientation within a layout container may be set. In this way, when the dimensions of the layout container change, the View or ViewGroup within the layout container maintains its original shape (e.g., aspect ratio) for scaling, such that the View or ViewGroup's proportion in a horizontal orientation within the layout container reaches the specified proportion after scaling and / or the View or ViewGroup's proportion in a vertical orientation within the layout container reaches the specified proportion after scaling.
[0099] Stretch capability means that a View or ViewGroup has adaptive stretch capability in a specified orientation within a layout container. For example, a margin value may be set for a View or ViewGroup in a specified orientation (horizontal and / or vertical) within a layout container. The margin value is the distance between the View or ViewGroup and the edges of the layout container. In this way, when the dimensions of the layout container change, the View or ViewGroup within the layout container maintains a margin with the layout container in the specified orientation and adaptively changes according to the dimensions of the layout container in the specified orientation.
[0100] Note that stretching in this embodiment of the application includes scaling up (increasing a dimension) and scaling down (decreasing a dimension) of a View or ViewGroup in a specified orientation. For example, a View or ViewGroup is stretched horizontally, including increasing or decreasing the width of the View or ViewGroup. A View or ViewGroup is stretched vertically, including increasing or decreasing the height of the View or ViewGroup.
[0101] The hiding capability is the capability to automatically hide a View or ViewGroup based on its priority during display. For example, the hiding priority of a View or ViewGroup in a layout container may be set. As an example, the hiding priority is used. When the dimensions of a layout container change and are insufficient to display all the designed Views or ViewGroups, hiding is performed based on the hiding priority of each View or ViewGroup.
[0102] Wrapping capability means that a View or ViewGroup in a layout container has adaptive wrapping capabilities. For example, a wrapping criterion value may be set for the layout container. If the total row width and spacing of a View or ViewGroup in the layout container is greater than the wrapping criterion value, another View or ViewGroup that is greater than the wrapping criterion value will be automatically wrapped for display.
[0103] It should be noted that the wrapping capability in this specification includes horizontal wrapping and vertical wrapping. Horizontal wrapping means that multiple child views are originally arranged in a horizontal direction, and the electronic device may automatically determine to display multiple child views in separate lines based on the width of the displayed layout container. Vertical wrapping means that multiple child views are originally arranged in a vertical direction, and the electronic device may automatically determine to display multiple child views in separate columns based on the height of the displayed layout container. In some other examples, vertical wrapping may be considered as the inverse operation of horizontal wrapping. Therefore, the wrapping capability in this application may also be expressed as branching capability, column capability, segmenting capability, section capability, etc. This is not particularly limited in this embodiment of the application.
[0104] Equalization means that the Views or ViewGroups in a layout container have automatic spacing capabilities. For example, the spacing between Views or ViewGroups at a specified orientation in a layout container may be set to be evenly divided. In this case, when the dimensions of the layout container change, the Views or ViewGroups in the layout container adaptively adjust the spacing of the Views or ViewGroups in the layout container based on the dimensions of the Views or ViewGroups and the dimensions of the layout container.
[0105] Proportion capability is the ability of a View or ViewGroup to maintain a fixed proportion in a specified orientation within a layout container. For example, a proportion of a layout container in a specified orientation (e.g., horizontal or vertical orientation) may be set. In this way, when the dimensions of the layout container change, the View or ViewGroup within the layout container maintains its original shape (e.g., aspect ratio) due to scaling, so that the proportion of the View or ViewGroup in the specified orientation within the layout container fills the specified proportion after scaling.
[0106] The expansion capability means that the layout container has the capability to automatically adjust the number of child views (Views or ViewGroups) that are displayed. The expansion capability includes general expansion capability and extended expansion capability. General expansion capability means that when the dimensions of the layout container change, the number of child views that are fully displayed in the layout container is determined based on the dimensions of the layout container, the dimensions of the child views in the layout container, and the default spacing. A fully displayed child view is also called a fully displayed child view, and means that all the content of the child view is displayed in the layout container. Extended expansion capability means that the layout container can display more child views that are not fully displayed. A partially displayed child view is also called a not fully displayed child view or a partially displayed child view, and means that the partial content of the child view is displayed in the layout container. For example, a dimension threshold in the layout container may be set. In this case, when the dimensions of the layout container change, the dimensions of the fully displayed child views in the layout container and the dimensions of the partially displayed content of the partially displayed child views are determined based on the dimensions of the child views in the layout container, the dimensions of the layout container, and the dimension threshold.
[0107] It should be noted that the expansion capability includes horizontal expansion capability and vertical expansion capability. The horizontal expansion capability means that the number of displayed child views is determined based on the width of the layout container of the horizontally arranged child view. The vertical expansion capability means that the number of displayed child views is determined based on the height of the layout container of the vertically arranged child view. In this specification, the horizontal expansion capability is used as an example for explanation. For the vertical expansion capability, please refer to the implementation form of the horizontal expansion capability. Details will not be described in this specification.
[0108] FIG. 3 shows a general procedure for implementing the adaptive layout capability of a View or ViewGroup according to an embodiment of the present application. First, a developer uses a development tool to develop an application interface. In the development process, capabilities that need to be used can be selected from the View and ViewGroup capability library (including Android native capabilities and adaptive layout capabilities extended in the present application) to obtain a layout file, complete the application interface development, and generate an application installation package. Then, the electronic device can download the application installation package from the application market, install the application installation package, and run it. When the application is run, the electronic device completes an automatic layout based on the layout file and the electronic device's environment (e.g., screen parameters), and draws the corresponding application interface, i.e., the interface that the user sees.
[0109] The following describes a specific solution for implementing the adaptive layout capability of a View or ViewGroup in this application.
[0110] When developing an application, a developer uses an Integrated Development Environment (IDE) tool to develop the application. The IDE tool integrates a set of integrated software development services, including code writing, analysis, compilation, debugging, etc. For example, a typical IDE tool for the Android system includes one of Android Studio and DevEco Studio.
[0111] 4(1) shows an example of a development interface 20 displayed when a developer develops an application. The development interface 20 includes an application directory tree 21, an application dependency package 22, and a development interface of an application display interface 1. The development interface of the application display interface 1 includes a layout file (e.g., 111.xml) 23 and Java source code (e.g., 222.java) 24.
[0112] The application directory tree 21 includes an application name, a compilation dependency package, an application package, and an application source code. A developer can quickly open a corresponding file by using the application directory tree 21, so that the developer can conveniently edit the file. For example, a developer may quickly open a Java source code file or a layout file by using a Java source code or a layout file in the application source code, and the developer may edit the Java source code file or the layout file to edit the layout of each display interface in the application.
[0113] It should be noted that before editing the layout of the display interface, libraries that the application development depends on need to be added. Specifically, the dependency libraries can be added to the application dependency package 22. For example, to develop an application on an Android system, it is necessary to depend on the External Libs and the Android API libraries.
[0114] After adding the dependency library, the developer may set information such as the hierarchical structure and attribute values of the Views and ViewGroups included in each display interface in the application, as well as the display resources of each View, by calling the corresponding API interface in the Java source code 24, or the developer may set information such as the hierarchical structure and attribute values of the Views and ViewGroups included in each display interface in the application, as well as the display resources of each View, in the layout file 23.
[0115] It should be noted that the View and ViewGroup provided in this embodiment of the present application have adaptive layout capabilities. In addition to the basic libraries of the Android system (External Libs or Android API libraries), it is necessary to further depend on the extended libraries of this application, such as the adaptive layout attribute package. In a specific implementation form, the adaptive layout attribute package includes the declaration of each adaptive layout capability of View and ViewGroup, information on the interface called by each adaptive layout capability, and a preset algorithm corresponding to each adaptive layout capability (the preset algorithm may include a measurement procedure used to layout the layout container provided with each adaptive layout capability, etc.). Therefore, when developing an application, the developer designs the layout file of the application by using the declaration of each adaptive layout capability, information on the interface called by each adaptive layout capability, etc. In other words, the layout file includes the View or ViewGroup provided with the adaptive layout capability. The developer packs the designed layout file, the preset algorithm corresponding to each adaptive layout capability, and other program codes and resources required for the application into the installation package of the application. In another specific implementation form, a developer designs a layout file of an application by using the declaration of each adaptive layout capability or information about the interface called by each adaptive layout capability, and packs the designed layout file of the application and other program codes and resources required by the application into an installation package of the application. In this example, an electronic device that subsequently installs the installation package of the application needs to have each adaptive layout capability provided in this embodiment of the present application, for example, pre-installing an algorithm module corresponding to each adaptive layout capability.
[0116] In other words, in a particular embodiment, the application installation package packed by the developer includes a layout file and a preset algorithm corresponding to the adaptive layout capability set in the layout file. In another particular embodiment, the application installation package packed by the developer may include a layout file but may not include a preset algorithm corresponding to the adaptive layout capability set in the layout file. In this embodiment, the electronic device that subsequently executes the application installation package pre-installs a preset algorithm module corresponding to the adaptive layout capability set in the layout file. For example, the pre-installed operating system of the electronic device may include a preset algorithm module corresponding to the adaptive layout capability, or the electronic device may download a preset algorithm module corresponding to the adaptive layout capability from a server (e.g., a server that provides the adaptive layout capability, or a server of the electronic device) and install the preset algorithm module.
[0117] After downloading and installing the application installation package, when the application is executed, the electronic device may obtain the attribute value of the View or ViewGroup of the adaptive layout capability based on the interface called by each adaptive layout capability, call the processing procedure corresponding to the layout measurement of each adaptive layout capability to complete the measurement and layout, and finally draw the display interface. The interface called by each adaptive layout capability and the processing procedure corresponding to each adaptive layout capability (e.g., the preset algorithm corresponding to each adaptive layout capability) will be described in detail below when the processing procedure of the electronic device is described.
[0118] For example, as shown in Figure 4(1), a developer may add an adaptive layout attributes package by using a view 25. As shown in the development interface 27 of Figure 4(2), an adaptive layout attributes package 26 is newly added to the application dependencies package.
[0119] It can be seen from the layout file 23 that "android:" leads to the attribute value of a native View or ViewGroup in the Android system, and "app:" leads to the attribute value of an extended View or ViewGroup in this application, i.e., a View or ViewGroup with adaptive layout capabilities. Alternatively, it can be seen from the Java source code 24 that the API interfaces corresponding to the adaptive layout capabilities invoked by a developer include, for example, setAttr1(), getAttr1(), setAttr2(), and getAttr2().
[0120] Then, the developer uses the IDE tool to pack the source code, resources (including layout files), dependency libraries, etc. of the developed application into an installation package (e.g., an APK file). In other words, the developer completes the development of the application. The installation package of the application is then released to the application market. Users may download and install the application on different electronic devices. It should be noted that electronic devices with different screen parameters use the same layout file to draw the display interface of the application.
[0121] For example, the electronic device in this embodiment of the present application may be a mobile phone, a tablet computer, a personal computer (PC), a personal digital assistant (PDA), a netbook, a wearable electronic device (such as a smart band or smart watch), an augmented reality (AR) device, a virtual reality (VR) device, an in-vehicle device, Vision, a smart car, and a smart speaker, etc. The specific form of the electronic device is not limited in this application.
[0122] 5 is a schematic diagram of the structure of the electronic device 100. It can be understood that the structure shown in this embodiment of the present application does not constitute a specific limitation on the electronic device 100. In some other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figure, or some components may be combined, or some components may be divided, or a different arrangement of components may be used. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.
[0123] The electronic device 100 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, a headset jack 170D, a sensor module 180, buttons 190, a motor 191, indicators 192, a camera 193, a display 194, a subscriber identity module (SIM) card interface 195, and the like.
[0124] 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 processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be separate components or may be integrated into one or more processors.
[0125] A memory may further be disposed in the processor 110 and configured to store instructions and data. In some embodiments, the memory in the processor 110 is a cache. The memory may store instructions or data that have just been used or that are used periodically by the processor 110. When the processor 110 needs to use the instructions or data again, the processor may retrieve the instructions or data directly from the memory. This avoids repeated accesses, reduces the latency of the processor 110, and improves system efficiency.
[0126] The internal memory 121 may be configured to store computer executable program code. The executable program code includes instructions. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system, applications necessary for at least one function (e.g., audio playback function and image playback function), and the like. The data storage area may store data created during use of the electronic device 100 (e.g., audio data, address book, and the like). In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, flash memory, or universal flash storage (UFS). The processor 110 executes instructions stored in the internal memory 121 and / or instructions stored in a memory located in the processor to perform various functions, applications, and data processing of the electronic device 100.
[0127] The external memory interface 120 may be used to connect to an external storage card, such as a Micro SD card, to expand the storage capabilities of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to achieve data storage functions. For example, files such as music and videos are stored on the external storage card.
[0128] The charging management module 140 is configured to receive a charging input from a charger. The charger can be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 may receive the charging input from the wired charger via the USB interface 130. In some embodiments of wireless charging, the charging management module 140 may receive the wireless charging input through a wireless charging coil of the electronic device 100. The charging management module 140 powers the electronic device through the power management module 141 while charging the battery 142.
[0129] The power management module 141 is configured to connect to the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to provide power to the processor 110, the internal memory 121, the display 194, the camera 193, the wireless communication module 160, etc. The power management module 141 may be further configured to monitor parameters such as battery capacity, battery cycle count, and battery health (leakage or impedance). In some other embodiments, the power management module 141 may alternatively be located in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may alternatively be located in the same device.
[0130] The wireless communication function of the electronic device 100 may be implemented via an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, a modem processor, a baseband processor, etc. The mobile communication module 150 can provide wireless communication solutions applied to the electronic device 100, including 2G, 3G, 4G, 5G, etc. The wireless communication module 160 can be applied to the electronic device 100 to provide wireless communication solutions including wireless local area network (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC) technology, infrared (IR) technology, etc.
[0131] In some embodiments, in the electronic device 100, the antenna 1 and the mobile communication module 150 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and another device by using a wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).
[0132] The electronic device 100 may implement a display function via a GPU, a display 194, an application processor, etc. The electronic device 100 may implement a photography function via a camera 193, an ISP, a video codec, a GPU, a display 194, an application processor, etc. The electronic device 100 may implement an audio function such as music playback and recording via an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, an application processor, etc.
[0133] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or may be touch buttons. The electronic device 100 receives key inputs and generates key signal inputs associated with user settings and function control of the electronic device 100. The motor 191 may generate vibration prompts. The motor 191 may be configured to provide incoming call vibration prompts and touch vibration feedback. For example, touch operations performed in different applications (e.g., taking pictures and playing audio) may correspond to different vibration feedback effects. The motor 191 may also correspond to different vibration feedback effects for touch operations performed in different areas of the display 194. Different application scenarios (e.g., time reminders, information reception, alarm clocks, and games) may also correspond to different vibration feedback effects. The touch vibration feedback effects may be further customized. The indicator 192 may be an indicator light and may be configured to indicate a charging status and a power change, or may be configured to indicate a message, a missed call, a notification, and the like. The SIM card interface 195 is configured to connect to a SIM card.
[0134] The sensor module 180 may include a touch sensor. The touch sensor may also be referred to as a "touch component." The touch sensor may be disposed on the display 194, and the touch sensor and the display 194 form a touch screen, also referred to as a "touch screen." The touch sensor is configured to detect touch operations performed on or near the touch sensor. The touch sensor may forward the detected touch operations to an application processor to determine a type of touch event. A visual output associated with the touch operation may be provided via the display 194. In some other embodiments, the touch sensor may alternatively be disposed on a surface of the electronic device 100 and in a different location than the display 194.
[0135] FIG. 6 is a block diagram of the software architecture of electronic device 100 according to one embodiment of the present invention.
[0136] In a layered architecture, software is divided into layers, with each layer having a distinct role and task. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers from top to bottom: application layer, application framework layer, Android runtime and system libraries, and kernel layer.
[0137] The application layer may include a series of application packages. As shown in FIG. 6, the application packages may include a gallery application, a clock application, etc. It should be noted that the gallery application or the clock application in this specification is an application installed by using the aforementioned application installation package. In other words, the layout file corresponding to the gallery application, the clock application, etc. includes a View or a ViewGroup provided with the aforementioned adaptive layout capability.
[0138] The application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. As shown in FIG. 6, the application framework layer may include an Activity Manager System (AMS), a Resource Manager, a Windows Manager System (WMS) (not shown), and a View System.
[0139] The AMS is configured to control all aspects of the application's lifecycle and activity stack. The resource manager is configured to provide access to non-code embedded resources such as strings, color settings, and user interface layouts. The WMS is configured to get the display size, determine if there is a status bar, perform screen locking, take screenshots, etc. The view system is configured to provide a set of views for creating the application user interface.
[0140] Specifically, after an application (e.g., a clock application) is started, the AMS responds to a touch event and starts the main Activity. In the main Activity, the attribute values of the View or ViewGroup included in the display interface are read from the resource manager by executing the inflate procedure in setContentView. In some examples, the layout file is first loaded in the resource manager, and then the corresponding interface is called by using the layout file to write the attribute values of each View and each ViewGroup included in the display interface. In some other examples, as an alternative, the interface may be directly called in the resource manager to write the attribute values of each View and each ViewGroup included in the display interface. It should be noted that the attribute values of the View and ViewGroup in this specification include Android native attribute values and attribute values related to the adaptive layout capability in this application. Then, the window drawing procedure of the view system is entered, and the drawing of the display interface is completed by executing the three procedures of measure, layout, and draw. The measurement procedure includes the Android native measurement procedure and the extended measurement procedure related to the adaptive layout capability in this application.
[0141] The Android runtime includes the kernel library and the virtual machine, and is responsible for scheduling and managing the Android system.
[0142] The kernel library contains two parts: the functions that need to be called in the java language and the Android kernel library.
[0143] The application layer and the application framework layer run on a virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is configured to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0144] The system library may include multiple functional modules, for example, a surface manager, media libraries, a three-dimensional graphics processing library (eg, OpenGL ES), and a 2D graphics engine (eg, SGL).
[0145] The surface manager is configured to manage the display subsystem and provide a blend of 2D and 3D layers for multiple applications. The media library supports multiple commonly used audio and video formats, as well as playback and recording of still image files. The media library may support multiple audio and video coding formats, e.g., MPEG4, H.264, MP3, AAC, AMR, JPG, PNG. The 3D graphics processing library is configured to implement 3D graphics drawing, image rendering, compositing, layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.
[0146] The kernel layer is a layer between the hardware and the software, and includes at least a display driver.
[0147] After the electronic device 100 installs the aforementioned applications, the internal memory 121 in the electronic device 100 stores a layout file of each display interface of the application. When the electronic device 100 detects an operation to execute the application, the electronic device 100 launches the application and starts drawing each display interface of the application based on the layout file of the display interface.
[0148] For the purpose of explanation, an example is used in which an electronic device 100 equipped with the Android system runs a clock application.
[0149] As shown in FIG. 7A, display interface 701 is a home screen interface displayed by electronic device 100 (e.g., specifically, a mobile phone). In response to detecting a user's manipulation of clock application icon 702 on display interface 701, the mobile phone launches the clock application and renders a home page 703 of the clock application. A layout container in which view 704 is located on home page 703 has expansion capabilities. View 704 changes depending on the layout container. The home page of the clock application may be understood as the first interface displayed after the clock application is executed.
[0150] It is further noted that for the purposes of illustration, an example in which an application is launched to display a home page is used herein. After an application is launched, in response to a user operation, the method provided in this application is also applicable when the mobile phone displays another interface (rather than a home page).
[0151] Specifically, after the clock application is started, the mobile phone creates an Activity corresponding to the application, i.e., the main Activity, and then generates a PhoneWindow instance by using the attach() method in the Activity. A DecorView is created in the PhoneWindow instance, and the screen parameters of the electronic device are obtained to determine the size and position (the positions of the four vertices, i.e., the positions of the top, bottom, left, and right boundaries) of the PhoneWindow and the DecorView. Then, the inflate procedure of the setContentView() method of the Window is called to read the layout file of the clock application. The layout file includes the Views and ViewGroups (e.g., the home page of the clock application) included in each display interface of the clock application, the hierarchical structure of these Views and ViewGroups, and the attributes of these Views and ViewGroups. The mobile phone calls the corresponding interface to write each attribute value of these Views and ViewGroups. In addition, the dimensions and positions of each ViewGroup and each View in the DecorView are determined level by level from the root based on the hierarchical structure of the view tree in the layout file. In other words, each View in the DecorView calculates its dimensions and position based on the dimensional constraints and the View's configuration (i.e., configured attribute values) transmitted by the parent layout container. The phone then draws all the Views to get the home page of the watch application.
[0152] Please note that the attributes of View and ViewGroup in this specification include Android native attributes and attributes related to adaptive layout capabilities in this embodiment of the application.Then, the mobile phone enters the window drawing procedure and completes the drawing of the display interface by performing three procedures: measure, layout, and draw.
[0153] The above measurements are used to calculate the actual size of the View. Starting from the performMeasure method, a MeasureSpec parameter is included. MeasureSpec indicates a 32-bit integer. The most significant 2 bits indicate the measurement mode (SpecMode), and the least significant 30 bits indicate the specification size (SpecSize) in the measurement mode. In other words, MeasureSpec is used to describe how to measure this View. The above layout is used to determine the position of the View in the parent layout container. This is performed after the parent layout container obtains the position parameters of the child View, invokes the layout method of the child View, and transfers the position parameters. The above drawing is used to draw the View, starting from the performDraw method. For the layout and drawing process, please refer to the related content of the prior art. The details will not be described again in this specification.
[0154] Note that the MeasureSpec of a DecorView is determined based on both the window dimensions and layout parameters (LayoutParams), and the MeasureSpec of a common View is determined based on both the MeasureSpec and LayoutParams of the layout container in which the common View is located (i.e., the parent layout container).
[0155] In this embodiment of the application, the window dimensions are determined based on the screen parameters of the mobile phone. The screen parameters include screen specification parameters, screen state parameters, etc. The screen specifications include the dimensions of the screen (e.g., the width and height of the screen). The screen specifications determine the dimensions of the area actually used by the mobile phone to display the application content. In some examples, the display form also affects the dimensions of the area actually used by the electronic device to display the application content. For example, if the display is a notched screen, the area of the notched screen is not used to display the application content. As another example, if the display is a curved screen, the curved area at the edge is not used to display the application content. The screen state includes whether the screen is in a landscape state or a portrait state. If the screen is a folding screen, the screen is in a folded state, a folded state in half, an unfolded state, etc. If the screen supports screen splitting, the dimensions of the window displayed by the current application are determined based on the screen parameters. It can be determined accordingly Half-folded means that part of the screen is folded and another part of the screen is unfolded, if the foldable screen supports multiple folds.
[0156] The LayoutParams of each of the View and ViewGroup includes the native attributes of the Android system, attributes related to the adaptive layout capability in this embodiment of the present application, etc. Therefore, in the measurement process, the mobile phone needs to perform measurement based on the native attributes of the Android system of the View and ViewGroup in the layout file, and further perform measurement based on the attributes related to the adaptive layout capability of the View and ViewGroup in the layout file. For the process in which the mobile phone performs measurement based on the native attributes of the Android system of the View and ViewGroup in the layout file, and the process in which the mobile phone performs layout based on the native attributes of the Android system of the View and ViewGroup in the layout file, please refer to the related content of the prior art. Details will not be described again in this specification.
[0157] For each adaptive layout capability extended in this embodiment of the present application, the following describes in detail how a developer designs a layout file that includes a View or ViewGroup with adaptive layout capabilities, and how an electronic device implements an adaptive layout based on the layout file when it runs an application.
[0158] (1) Expansion capacity When developing an application, after adding a dependency of the adaptive layout attributes package, the developer may set a ViewGroup with extensibility on the display interface. Specifically, when editing the layout file of the display interface, the developer may set an attribute value related to the extensibility of the ViewGroup in the layout file (e.g., an XML file), or may set an attribute value related to the extensibility of the ViewGroup in a Java source code file by adding a calling interface.
[0159] Table 1 shows an example of attributes related to expansion capabilities.
[0160] [Table 1]
[0161] It should be noted that when setting the attributes of the layout container, the developer may enable the general expansion capability of the layout container through the general expansion capability enablement and set the default spacing between child views in the layout container. The ability to display partial content of the last child view displayed in the layout container may be further enabled by the extended expansion capability enablement. The child view displaying partial content may be used to prompt the user that there are child views that are not displayed or not fully displayed in the current layout container, so that the user can perform a corresponding operation to see the child views that are not displayed. Furthermore, a dimension threshold and a spacing threshold between child views in the layout container may be set. Thereafter, when the application is run to draw the child views, the electronic device determines the number of child views to be displayed based on the dimensions of the layout container, the dimension thresholds of the child views, the spacing thresholds, etc., adjusts the spacing between the child views, etc.
[0162] The meaning of each attribute related to the expansion capability and the effect on the display of the layout container and child views will be described in detail below with reference to the accompanying drawings.
[0163] In some embodiments, a developer may enable a general expansion capability for a layout container and set a default spacing for the layout container, in which case the electronic device determines how many child views can actually be fully displayed within the layout container based on the width of the layout container, the width of each contained child view, and the default spacing.
[0164] For example, a layout container is configured to include five horizontally arranged child views, child view A through child view E.
[0165] FIG. 8(1) is an effect diagram of a layout container displayed by electronic device 1. In this case, the width of the layout container displayed by electronic device 1 is equal to or greater than the sum of the widths of the child views in the layout container + default spacing x (number of child views - 1). Therefore, the layout container on electronic device 1 may display all child views (child view A to child view E) horizontally, and the child views maintain the default spacing. In this case, child view A to child view E are fully displayed.
[0166] FIG. 8 (2) is an effect diagram of the layout container displayed by the electronic device 2. In this case, the width of the layout container displayed by the electronic device 2 < the sum of the widths of the child views in the layout container + default spacing × (number of child views - 1). Therefore, the layout container on the electronic device 2 cannot fully display all the child views. Therefore, the electronic device 2 may determine the number of child views that can be fully displayed on the electronic device 2 based on the actual width of the layout container, the widths of the child views, and the default spacing. For example, the layout container on the electronic device 2 can fully display up to four child views at a time, i.e., child view A to child view D, and the child views maintain the default spacing. In this case, child view A to child view D are fully displayed.
[0167] It should be noted that the layout container supports scroll viewing. In other words, the user may manipulate the layout container to view another child view that is not currently displayed on the screen. For example, in response to a slide left operation performed by a user at the location of the layout container on the electronic device 2, the electronic device 2 displays the interface shown in (3) of FIG. 8 and displays the child view E on the interface. In this case, it can be seen that the layout container on the electronic device 2 can also fully display up to four child views.
[0168] In a specific implementation, an expansion capability may be set for a layout container in which an image view, a button view, etc. are located. When the width of the layout container changes, the number of image views or button views displayed may be automatically determined based on the width of the layout container, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the general expansion capability in the present solution can enable electronic devices with different screen parameters to present different display effects based on the same layout setting, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0169] In some other embodiments, the developer may enable the layout container's extended expansion capability and further set attributes such as dimension threshold and spacing threshold. In this case, the electronic device determines whether the layout container can fully display all child views based on the layout container's width, the width of each child view, and the default spacing. If all child views are not fully displayed, the default spacing is reduced until the spacing threshold is reached. If all child views still cannot be fully displayed when the default spacing is reduced to the spacing threshold, the number of child views that can actually be fully displayed is determined based on the layout container's actual dimensions, the width of each child view, and the dimension threshold.
[0170] For example, a layout container is configured to include five horizontally arranged child views, child view A through child view E.
[0171] FIG. 9(1) is an effect diagram of a layout container displayed by electronic device 1. In this case, the width of the layout container displayed by electronic device 1 is equal to or greater than the sum of the widths of the child views in the layout container + default spacing x (number of child views - 1). Therefore, the layout container on electronic device 1 may display all child views (child view A to child view E) horizontally, and the child views maintain the default spacing. In this case, child view A to child view E are fully displayed.
[0172] Alternatively, the width of the layout container displayed by electronic device 1 < sum of the widths of the child views in the layout container + default spacing × (number of child views − 1), but the width of the layout container displayed by electronic device 1 ≧ sum of the widths of the child views in the layout container + spacing threshold × (number of child views − 1). Electronic device 1 may also adjust the spacing between the child views so that the layout container on electronic device 1 can fully display all child views (child view A through child view E), and the spacing between the child views is greater than or equal to the spacing threshold.
[0173] FIG. 9 (2) is an effect diagram of the layout container displayed by the electronic device 2. In this case, the width of the layout container displayed by the electronic device 2 < the sum of the widths of the child views in the layout container + the spacing threshold × (the number of child views - 1). Therefore, the layout container on the electronic device 2 cannot fully display all the child views. In this case, the electronic device needs to display the child views of the partial content. The electronic device 2 may determine the number of child views that may be fully displayed by the layout container based on the actual dimensions of the layout container, the width of each child view, the dimension threshold, and the spacing threshold. For example, the electronic device 2 determines that the layout container can display up to four complete child views at a time (child view A through child view D) and the partial content of one child view (the partial content of child view E), and the spacing between the child views is equal to or greater than the spacing threshold.
[0174] FIG. 9 (3) is an effect diagram of a layout container displayed by the electronic device 3. In this case, the width of the layout container displayed by the electronic device 3<the sum of the widths of the child views in the layout container+the spacing threshold×(the number of child views−1). Therefore, the layout container on the electronic device 3 cannot fully display all the child views. In this case, the electronic device needs to display child views that display only partial content. The electronic device 3 may determine the number of child views that can be displayed by the layout container based on the actual dimensions of the layout container, the width of each child view, the dimension threshold, and the spacing threshold. For example, the electronic device 3 determines that the layout container can display up to three complete child views at a time (child view A through child view C) and partial content of one child view (partial content of child view D), and the spacing between the child views is equal to or greater than the spacing threshold.
[0175] It should be noted that the layout container supports scroll browsing. In other words, the user may manipulate the layout container to view another child view that is not currently displayed on the screen. For example, in response to a slide left operation performed by the user at the location of the layout container on the electronic device 3, the electronic device 3 displays the interface shown in (4) of FIG. 9, and displays all the content of child view D and partial content of child view E on the interface.
[0176] From the above description, it can be seen that in this embodiment of the present application, the number of displayed child views may be adaptively reduced based on changes in the layout container, child views that display only partial content may also be displayed, and the dimensions of the partial content displayed by the child views may maintain a fixed value (i.e., the dimension threshold). In this way, child views that display only partial content may be used to prompt the user that there are still child views that are not displayed in the layout container. In addition, by maintaining the dimension threshold as a fixed value, the user may not feel irregular confusion due to different screen dimensions resulting in different dimensions of child views that display partial content.
[0177] The following provides an example of a layout file (XML file). A layout container with stretch capability enabled is set in the layout file. In addition, the layout container contains four child views, namely, four linear layout containers, each of which stores one image view and one text view. Note that since the stretch capability needs to support scroll browsing, the entire layout container with stretch capability needs to be placed in a ScrollView, the horizontal stretch capability needs to be placed in a HorizontalScrollView, and layout_width needs to be set to match_parent. The vertical stretch capability can be deduced by analogy. / *Layout extension example* / <HorizontalScrollView xmlns:android=“http: / / schemas.android.com / apk / res / android” xmlns:app=“http: / / schemas.android.com / apk / res-auto” android:layout_height="wrap_content" / / Sets the height of the layout container android:layout_width="match_parent" / / Set the width of the layout container / * Omit other configurations * / > <hwLayout / * Omit other configurations * / android:orientation="horizontal" / / Set the layout orientation to horizontal app:enableExtensionCapability="true" / / Enable the general extension capability of the layout container app:enableExtendedExtensionCapability="true" / / Enable the extended extension capability of the layout container app:dimensionThreshold="32dp" > / / Set the dimension of the last child view displayed within the layout container <LinearLayout / * Omit other configurations * / > / / Set the child view within the layout container - a linear layout container <ImageView / * Omit other configurations * / > / / Set the child view within the linear layout container - an image view android:background="@drawable / shape_drawable" android:src="@drawable / ic_group_04" / > <TextView / * Omit other configurations * / > / / Set another child view within the linear layout container - a text view android:text="Game Circle" / > <LinearLayout / * Omit other configurations * / > / / Set another child view within the layout container - a linear layout container <ImageView / * Omit other configurations * / > / / Set the child view within the layout container - an image view within another linear layout container android:background="@drawable / shape_drawable" android:src="@drawable / ic_group_05" / > <TextView / *Other configurations omitted* / / / Set another child view within another linear layout container - text view within the layout container android:text="Optical illusion" / > <LinearLayout / *Other configurations omitted* / > <ImageView / *Other configurations omitted* / android:background="@drawable / shape_drawable" android:src="@drawable / ic_group_01" / > <TextView / *Other configurations omitted* / android:text="Fashion talent" / > <LinearLayout / *Other configurations omitted* / > <ImageView / *Other configurations omitted* / android:background="@drawable / shape_drawable" android:src="@drawable / ic_group_02" / > <TextView / *Other configurations omitted* / android:text="Travel group" / > < / *Other configurations omitted* / >
[0178] The foregoing embodiments are solutions for developers to design an adaptive display interface layout by setting attribute values related to the extension capabilities of Views or ViewGroups within a layout file (e.g., an XML file). Alternatively, by adding a call interface, the attribute values related to the extension capabilities of Views or ViewGroups may be set in a Java source code file.
[0179] Table 2 shows an example of an interface that corresponds to attribute values related to the extensibility capabilities of a View or ViewGroup.
[0180] [Table 2]
[0181] The meaning of the extension capability is described in detail above. The developer may configure a layout file based on the layout design of each display interface in the application by referring to the extension capability, another adaptive layout capability, and the basic layout capability (e.g., Android native attributes), pack the layout file, other source code and resources, etc. of the application into an installation package (e.g., APK file), and release the installation package to the application market. The electronic device downloads the installation package from the application market and installs the application. The following describes in detail a solution for implementing an adaptive layout based on the aforementioned layout file when the electronic device runs the application.
[0182] Specifically, the mobile phone performs the measurement procedure shown in Fig. 10A for each layout container in the layout file. The method specifically includes the following steps.
[0183] S1001: Read the layout parameters of the layout container.
[0184] The layout parameters of the layout container are read from a layout file (e.g., an XML file) and include layout information such as the hierarchical relationship of the layout container on the display interface (including the parent layout container of the layout container, and the child views of the layout container, etc.), the dimensions and position of the layout container (the dimensions and position are not necessarily fixed values, but may be constraints), the inner margins of the layout container, the dimensions of and spacing between child layout containers contained within the layout container, and the dimensions of and spacing between views contained within the layout container.
[0185] For example, the layout container in this specification may be a layout container in any layer of the display interface. For example, the layout container in this specification may be a layout container in an upper layer of the display interface, for example, the content view in FIG. 1(2). In this case, the electronic device obtains the screen parameters (including the screen type, screen dimensions, screen state, etc.) of the electronic device to determine the display size (i.e., dimensions), display position, etc. of the content view. As another example, the layout container in this specification may alternatively be a layout container in an intermediate layer of the display interface, for example, the view group 3. In this case, the electronic device sequentially determines the dimensions and positions of all layout containers from top to bottom until the display size (i.e., dimensions), display position, etc. of the view group 3 are determined based on the screen parameters and hierarchical relationships of the electronic device shown in FIG. 1(2).
[0186] S1002: Determine whether the layout container enables expansion capabilities.
[0187] If it is found based on the layout file that the layout container does not enable the enhanced growth capability and does not enable the general growth capability, the native measurement procedure of the Android system is used for measurement. If the layout container does not enable the enhanced growth capability but enables the general growth capability, the mobile phone determines the number of child views to be displayed based on the dimensions and default spacing of the layout container and arranges the child views. In this case, all child views displayed by the mobile phone are fully displayed. If the layout container enables the enhanced growth capability, step S1003 is executed.
[0188] It should be noted that the attribute values enabling the extension capabilities (general extension capabilities and extended extension capabilities) included in the layout file may be set by a developer during application development, and the extension capabilities of the layout container are fixedly enabled or disabled. In some other embodiments, when developing an application, the developer may instead set the extension capabilities of the layout container to be set by a user. In this case, the user can enable the extension capabilities of the layout container or disable the extension capabilities of the layout container.
[0189] S1003: The number N1 of child views that can be completely displayed by the layout container is calculated.
[0190] Specifically, the number of child views N1 that can be displayed is predetermined based on the dimensions of the layout container, the dimensions of each child view, the default spacing, and the dimension threshold, e.g., N1(rounded)=(layout container width-dimension threshold-layout container inner margin) / (child view width+default spacing).
[0191] S1004: The remaining space of the layout container is calculated based on N1.
[0192] For example, layout container remaining space (± double) = (layout container width - dimension threshold - layout container inner margin) - N1 * (child view width + default spacing).
[0193] S1005: Calculate the variation ΔM in the spacing between child views based on N1 and the remaining space of the layout container.
[0194] For example, the variation in spacing between child views ΔM (± double) = remaining space in layout container / N1.
[0195] S1006: The interval M is calculated based on the variation ΔM of the interval between child views and the default interval.
[0196] For example, spacing M (± double) = spacing variation between child views ΔM + default spacing.
[0197] S1007: It is determined whether the interval M is equal to or greater than the interval threshold set in the layout file.
[0198] If the interval M is less than the interval threshold, the number N1 of child views that can be displayed is decreased by one, and then the interval between the child views continues to be adjusted, i.e., step S1008 is executed. If the interval M is greater than or equal to the interval threshold, the current child view may be positioned based on the interval, and step S1009 is executed.
[0199] S1008: N1=N1-1, then execute step S1004.
[0200] S1009: Calculate the number Na of child views for which space expansion needs to be performed and the number Nb of child views for which space contraction needs to be performed, where Na+Nb=N1.
[0201] S1010: The intervals between the N1 child views are updated.
[0202] It should be noted that in this embodiment, the remaining space in the layout container, excluding the child view display space, the dimension threshold display space, and the inner margin space reserved in the layout container, needs to be evenly allocated as the spacing between child views (including child views that display partial content). Since electronic devices perform display by using pixels as a unit, it is generally not possible to divide the remaining space strictly evenly. Therefore, after the spacing that satisfies the condition (greater than or equal to the spacing threshold) is obtained, the spacing between all child views may be further fine-tuned so that the spacing between the child views fully occupies the remaining space. For example, the obtained spacing that satisfies the condition is rounded up by using pixels as a unit to obtain the widened spacing. In this case, the number of child views Na for which spacing expansion is performed = fractional part of the spacing x N1. The obtained spacing that satisfies the condition is rounded down by using pixels as a unit to obtain the narrowed spacing. In this case, the number of child views Nb for which spacing reduction is performed = N1 - Na.
[0203] For example, the number of child views that need to be displayed, obtained by the calculation in the previous step, is 5, and the spacing is 3.2 pixels. In this case, the expanded spacing obtained after the spacing is rounded up is 4. Number of child views for which the spacing expansion needs to be performed = (3.2-3) x 5 = 1, i.e., the spacing with one of the child views needs to be determined as 4 pixels. Narrowed The spacing is 3. The number of child views for which spacing contraction needs to be performed=5-1=4, that is, the spacing with each of the four child views is determined as 3 pixels. Specifically, the manner of determining the child views for which spacing expansion needs to be performed and the child views for which spacing contraction needs to be performed is not particularly limited in this embodiment of the present application. Certainly, the spacing between child views in a layout container may be adjusted by using another method as an alternative.
[0204] In this way, spacing values between child views within a layout container are kept approximately equal, within ±1 pixel.
[0205] Note that in this embodiment, the layout container displays the partial content of the (N1+1)th child view.
[0206] It is further noted that for the purposes of explanation, an example in which the widths of the child views contained within the layout container are equal is used herein. If the widths of the child views are not equal, the extended expansion capability may not be enabled by default. In other words, the layout container does not display child views that have only partial content. Specifically, the electronic device may need to perform a calculation based on the order of arranging all child views contained within the layout container, the width of each child view, and the default spacing to determine the number of child views that can be fully displayed by the layout container, and arrange the child views that can be fully displayed based on the default spacing.
[0207] It can be seen that when electronic devices having different screen dimensions (e.g., a mobile phone and a tablet computer) use the same layout file (including a layout container with expansion capabilities), the final rendered application interface may present different layout effects according to the measurement procedure of FIG. 10A.
[0208] For example, a mobile phone has a screen width of 720 pixels, and a tablet computer has a screen width of 1280 pixels. Both the mobile phone and the tablet computer use the same installation package to install the application market. A layout file corresponding to the application market home page includes a layout container configured to display high-quality applications, where the layout container enables enhanced growth capabilities. In addition, the layout container includes 10 child views arranged horizontally, where each child view corresponds to one application icon. Each child view has a width of 120 pixels, a default spacing of 40 pixels, and a dimension threshold (i.e., the width of a child view that is not fully displayed) of 80 pixels. In addition, the width of the layout container is equal to the device screen width, and the inner margin is 0 pixels.
[0209] In this case, when the mobile phone renders the application market home page and executes the measurement procedure of FIG. 10A, the number of child views that can be displayed by the mobile phone is calculated as follows: N1=(layout container width-dimension threshold-layout container inner margin) / (child view width+default spacing)=(720-80-0) / (120+40)=4. In other words, the mobile phone can fully display four child views and incompletely display one child view. The mobile phone displays the interface 101 shown in FIG. 10B(1), where the layout container 102 includes four fully displayed application icons and one incompletely displayed application icon.
[0210] When the tablet computer renders the application marketplace home page and performs the measurement procedure of FIG. 10A, the number of child views that can be displayed by the tablet computer is calculated as follows: N1=(layout container width-dimension threshold-layout container inner margin) / (child view width+default spacing)=(1280-80-0) / (120+40)=7.5. In other words, the tablet computer can fully display seven child views and incompletely display one child view. The tablet computer displays the interface 103 shown in FIG. 10B(2), where the layout container 104 includes seven fully displayed application icons and one incompletely displayed application icon.
[0211] FIG. 11 is another schematic diagram of an adaptive application interface layout method according to an embodiment of the present application. In the application development phase, a developer may set attributes related to the extension capabilities in a layout file, such as an XML file. For example, the developer enables the extension capabilities, sets a default interval, sets an interval threshold, enables the extended extension capabilities, and sets a dimension threshold. After that, the developer packs the layout file, other application codes and resources, etc. into an installation package, and releases the installation package to an application market. Then, a user may download the installation package from the application market by using an electronic device, and install the application. When the electronic device runs the application, the layout module in the electronic device parses the attributes related to the extension capabilities from the layout file to obtain attribute values related to the extension capabilities, and sends the attribute values to the extension module in the electronic device. Then, the layout module performs measurement and starts the extension capabilities process. In other words, the extension module calculates parameters of the related views, such as the dimensions of the views, based on the attribute values related to the extension capabilities. The layout module performs layout based on the updated parameters of the views to obtain the positions of the views on the specific display interface of the application. Finally, the electronic device may draw and display the specific display interface. In a specific example, the layout module may be a measurement module and a layout module in the native view system of the Android system. The extension module may be a newly added function module in the measurement module in the view system, and may perform the relevant steps of FIG. 10A.
[0212] (2) Proportional Ability When developing an application, after adding a dependency of the adaptive layout attributes package, the developer may set a layout container (i.e., a ViewGroup) with percentage capabilities on the display interface. Specifically, when editing the layout file of the display interface, the developer may set attribute values related to the percentage capabilities of the ViewGroup in the layout file (e.g., an XML file), or may set attribute values related to the percentage capabilities of the ViewGroup in a Java source code file by adding a calling interface.
[0213] Table 3 shows an example of attributes related to percentage ability.
[0214] [Table 3]
[0215] Note that when setting the attributes of the layout container, the developer may enable the layout container's percentage capabilities through percentage capability enablement and set percentages for each child view in the layout container (i.e., a View or ViewGroup stored in the layout container). Then, when running the application and drawing each child view into the layout container, the electronic device draws the child views into the layout container based on the dimensions of the layout container and the percentages of the child views.
[0216] The meaning of each attribute related to the ratio capability and the effect on the display of the layout container and child views will be described in detail below with reference to the accompanying drawings.
[0217] As shown in (1) of Figure 12, the ratio of a child view to a layout container in horizontal orientation is the ratio of the child view's width (X) to the total width (Y) of the layout container, i.e., X / Y, and the ratio of a child view to a layout container in vertical orientation is the ratio of the child view's height (R) to the total height (T) of the layout container, i.e., R / T.
[0218] When the layout container's attribute is set, the attribute value of percentage_enabled is set to "true", and for the child view, the percentage is set to M (M is a ratio). The specific meaning of percentage M (horizontal percentage or vertical percentage) may be determined based on the layout orientation of the layout container.
[0219] For example, if the layout orientation of the layout container is horizontal (also called horizontal), the percentage M represents the percentage of the child view in the horizontal orientation, i.e., the ratio of the child view's width to the total width of the layout container. In this case, when the width of the layout container changes, the width of the child view within the layout container is scaled until the scaled width of the child view occupies M of the total width of the layout container. However, the height of the child view does not change according to the height of the layout container. For example, compared with the dimensions of the layout container shown in FIG. 12(1), the width of the layout container shown in FIG. 12(2) changes (changes to Y') but the height remains unchanged. In this case, the width of the child view changes accordingly to X', where X'=M×Y', and the height of the child view remains unchanged and remains R. As another example, compared with the dimensions of the layout container shown in FIG. 12(1), the width of the layout container shown in FIG. 12(3) changes (changes to X') and the height also changes (changes to T'). In this case, the width of the child view changes accordingly to X', where X'=M×Y', and the height of the child view remains unchanged, remaining at R. Note that herein, no layout parameters are set in the layout file to change the height of the child view. In conclusion, the percentage capability applies only to the dimensions of the child view in the layout orientation of the layout container (in this example, the layout orientation is horizontal), and not to the dimensions of the child view in another orientation (e.g., in this example, vertical).
[0220] If the layout orientation of the layout container is vertical (also called vertical orientation), then the percentage M represents the child view's percentage in vertical orientation, i.e., the ratio of the child view's height to the total height of the layout container. In this case, when the layout container's height changes, the scaled height of the child view increases to the total height of the layout container. heightThe height of the child view in the layout container is scaled until it occupies M of the child view. However, the width of the child view does not change according to the width of the layout container. For example, compared with the dimensions of the layout container shown in FIG. 12(1), the height of the layout container shown in FIG. 12(4) changes (changes to T') but the width remains unchanged. In this case, the height of the child view changes accordingly to R', where R'=M×T', and the width of the child view remains unchanged and remains X. As another example, compared with the dimensions of the layout container shown in FIG. 12(1), the height of the layout container shown in FIG. 12(5) changes (changes to T') and the width also changes (changes to Y'). In this case, the height of the child view changes accordingly to R', where R'=M×T', and the width of the child view remains unchanged and remains X. It should be noted that in this specification, no layout parameters for changing the width of the child view are set in the layout file. In conclusion, the percentage capabilities only apply to the dimensions of child views in the layout container's layout orientation (in this example, the layout orientation is vertical), not to the dimensions of child views in a different orientation (e.g., in this example, horizontal).
[0221] It should be noted that in the above, an example in which only one parameter, i.e., the percentage M, is set is used for explanation. In this example, the specific meaning of the percentage M (horizontal percentage or vertical percentage) may be determined based on the layout orientation of the layout container. In some other examples, different parameters may be set to represent the percentage in the horizontal orientation (e.g., the percentage P) and the percentage in the vertical orientation (e.g., the percentage Q) instead. This is not limited in this embodiment of the present application.
[0222] For example, a developer may set the proportion of a child view to 50%. As shown in (1) of Figure 12, the dimensions of the layout container on electronic device 1 are 1080x540 (width x height, in pixels) and the dimensions of the child view are 540x270. In this case, the proportion of the child view in both horizontal and vertical orientations amounts to 50%.
[0223] In some examples, the layout orientation of the layout container is set to horizontal. As shown in FIG. 12(2), the dimensions of the layout container on electronic device 2 are 2160×540 (in pixels). In this case, the height of the layout container on electronic device 2 is the same as the height of the layout container on electronic device 1, but the width is increased. Therefore, the child view is scaled based on the horizontal percentage (50%), and the dimensions of the child view are calculated as 1080×270 (in pixels). As shown in FIG. 12(3), the dimensions of the layout container on electronic device 3 are 2160×1080 (in pixels). In this case, both the width and the height of the layout container on electronic device 3 are larger than the width and the height of the layout container on electronic device 1. Therefore, the child view is scaled based on the horizontal percentage (50%), and the dimensions of the child view are calculated as 1080×270 (in pixels).
[0224] In some other examples, the layout orientation of the layout container is set to vertical. As shown in (4) of FIG. 12, the dimensions of the layout container on electronic device 4 are 1080×1080 (in pixels). In this case, the height of the layout container on electronic device 4 is the same as the height of the layout container on electronic device 1, but the height is increased. Thus, the child view is scaled based on the vertical percentage (50%), and the dimensions of the child view are calculated as 540×540 (in pixels). As shown in (5) of FIG. 12, the dimensions of the layout container on electronic device 5 are 2160×1080 (in pixels). In this case, the height of the layout container on electronic device 5 is 2160×1080 (in pixels). and width is the height of the layout container on electronic device 1 and width Therefore, the child view is scaled based on the vertical percentage (50%) and the child view's dimensions are calculated as 540x540 (in pixels).
[0225] In a particular implementation, a ratio capability may be set for a layout container in which a text view, a button view, an image view, etc. are located. When the width or height of the layout container changes, the width or height of the text view, the button view, or the image view may automatically and adaptively change based on the width or height of the layout container, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the ratio capability in the present solution can enable electronic devices with different screen parameters to present different display effects based on the same layout setting, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0226] The above embodiment is described by using one child view in a layout container, if the layout container includes multiple child views, a percentage may be set for each of the multiple child views or a percentage may be set for a portion of the multiple child views.
[0227] In some embodiments, a percentage is set for each of the multiple child views. For a method of scaling each child view in a specified orientation, please refer to the method of scaling a child view in a specified orientation in the previous embodiment. Details will not be described again in this specification. It should be noted that if the sum of the percentages of all child views is greater than 100%, truncation occurs, that is, not all child views can be displayed in the layout container. In some examples, when a developer sets a percentage of a child view and the sum of the specified percentages is greater than 100%, the developer may be prompted to change the percentage of some child views, or the developer may be prompted to set another capability of the layout container, such as the hiding capability. In some other examples, when the electronic device displays the layout container, the user may be prompted to perform an interface adjustment. If the sum of the percentages of all child views is less than 100%, white space residue occurs. In some other examples, the user may be prompted to select or increase the spacing between child views by default.
[0228] In some other embodiments, if some child views in a layout container have percentages and some child views do not, the dimensions of each percentageed child view in the specified orientation may be calculated first, and then the remaining space in the layout container is allocated to the non-percented child views. For example, after the dimensions of each percentageed child view in the specified orientation have been determined, the remaining space in the layout container is allocated equally to the non-percented child views.
[0229] 13(1), a layout container includes three child views: child view 1, child view 2, and child view 3. The layout orientation of the layout container is horizontal.
[0230] As shown in (2) of Figure 13, if a percentage, for example 20%, is set for each of child views 1 to 3, when the width of the layout container changes, the percentage of each of child views 1 to 3 to the width of the layout container remains 20%.
[0231] As shown in FIG. 13(3), if a percentage, say 20%, is set for child view 1, but no percentage is set for child view 2 and child view 3, when the width of the layout container changes, child view 1's percentage of the layout container's width initially remains 20%. Then, the remaining space in the layout container (80%) is allocated equally to child view 2 and child view 3, i.e., child view 2 and child view 3 each occupy 40% of the layout container's width. In this example, the percentages of child view 1, child view 2, and child view 3 Sum of Note that exactly equals 100%. In other words, there is no spacing between the child views. In some instances, if a developer sets percentages for child views and the sum of the specified percentages equals 100%, the developer may be prompted for no spacing between the child views. If the developer wants to have spacing between child views, the developer may set the percentages for the child views. Percentage of The sum may be set to less than 100%.
[0232] The application of the percentage capabilities of a layout container is described below with reference to the case where the interface of a layout container with percentage capabilities enabled is nested within another layout container with percentage capabilities enabled.
[0233] As shown in the interface illustrated in FIG. 14(1), layout container 1400 includes child view 1401 and child view 1402. Layout container 1400 has the percentage capability enabled, and the layout orientation of layout container 1400 is vertical. Percentage A (e.g., 60%) of child view 1401 is set. In this case, the percentage of child view 1401 is a vertical percentage. In other words, the height of child view 1401 changes according to the height of layout container 1400, and the ratio of the height of child view 1401 to the height of layout container 1400 remains at percentage A.
[0234] Each of child view 1401 and child view 1402 is essentially a ViewGroup, i.e., a layout container, also called a layout container view. Child view 1402 includes play views, such as "previous", "play", "next", and "see more". Child view 1401 also enables the percentage capability, and the layout orientation of child view 1401 is horizontal. Child view 1401 includes child view 1403 (an image view) and child view 1404 (multiple text views). A percentage B (e.g., 30%) is set for child view 1403. In this case, the percentage of child view 1403 is a horizontal percentage. In other words, the width of child view 1403 is the width of layout container 140. 0 The height of the child view 1403 changes depending on the width of the layout container 140 0 The ratio of the width of the layout to the width of the layout remains at ratio B.
[0235] It can be seen that the height of the child view 1403 changes according to the height of the layout container 1400, the width of the child view 1403 changes according to the width of the child view 1401, and the width of the child view 1401 changes according to the width of the layout container 1400. Thus, the width and height of the child view 1403 change according to the width and height of the layout container 1400, but the aspect ratio of the child view 1403 may change. In other words, the manner in which the width and height of the child view 1403 change herein is different from the manner in which the child view maintains the aspect ratio for scaling in a scaling capability, so that more display requirements of the application interface may be met.
[0236] For example, as shown in (1) of FIG. 14, if layout container 1400 on electronic device 1 has dimensions of 1080×540 (width×height, in pixels), child view 1401 (i.e., child layout container) has dimensions of 1080×324 (in pixels) (height of child view 1401=(540×60%) pixels), child view 1402 has dimensions of 1080×216 (in pixels) (height of child view 1402=(540-324) pixels), child view 1403 has dimensions of 324×324 (in pixels) (width of child view 1403=(1080×30%) pixels), and child view 1404 has dimensions of 756×324 (in pixels).
[0237] As shown in (2) of FIG. 14, when the dimensions of layout container 1400 on electronic device 2 are 1280×540 (width×height, in pixels), child view 1401 (i.e., child layout container) are 1280×324 (in pixels) (height of child view 1401=(540×60%) pixels), child view 1402 are 1280×216 (in pixels) (height of child view 1402=(540-324) pixels), child view 1403 are 384×324 (in pixels) (width of child view 1403=(1280×30%) pixels), and child view 1404 are 896×324 (in pixels).
[0238] As shown in (3) of FIG. 14, when the dimensions of the layout container 1400 on the electronic device 3 are 1080×640 (width×height, in pixels), the dimensions of the child view 1401 (i.e., the child layout container) are 1080×384 (in pixels) (height of the child view 1401 = (640×60%) pixels), the dimensions of the child view 1402 are 1080×256 (in pixels) (height of the child view 1402 = (640 - 384) pixels), the dimensions of the child view 1403 are 324×384 (in pixels) (width of the child view 1403 = (1080×30%) pixels), and the dimensions of the child view 1404 are 756×384 (in pixels).
[0239] As shown in (4) of FIG. 14, when the dimensions of the layout container 1400 on the electronic device 4 are 1280×640 (width×height, in pixels), the dimensions of the child view 1401 (i.e., the child layout container) are 1280×384 (in pixels) (height of the child view 1401 = (640×60%) pixels), the dimensions of the child view 1402 are 1280×256 (in pixels) (height of the child view 1402 = (640 - 384) pixels), the dimensions of the child view 1403 are 384×384 (in pixels) (width of the child view 1403 = (1280×30%) pixels), and the dimensions of the child view 1404 are 896×384 (in pixels).
[0240] The following provides an example of the layout file (XML file) of the layout container 1400. <hwLayout / / Set the layout parameters of the layout container 1400 xmlns:android=“http: / / schemas.android.com / apk / res / android” xmlns:app=“http: / / schemas.android.com / apk / res-auto” / * Other configurations are omitted * / app:ratioEnable = “true” / / Enable the ratio ability of the layout container 1400 android:orientation="vertical" / / The layout orientation of layout container 1400 is vertical orientation, which means that the ratio set for the child views within the layout container is the vertical ratio <hwLayout / / Set the layout parameters of child view 1401 within layout container 1400 / * Other configurations are omitted * / app:ratioEnable="true" / / Enable the ratio ability of child view 1401 android:orientation="horizontal" / / Set the layout orientation of child view 1401 to horizontal orientation, which means that the ratio set for the child views nested within child view 1401 is the horizontal ratio app:ratio="140%"> / / Set the vertical ratio of child view 1401 <ImageView / / Set the layout parameters of child view 1403 nested within child view 1401 / * Other configurations are omitted * / app:ratio="30%" / > / / Set the horizontal ratio of child view 1403 <hwlayout 子ビュー1401内に入れ子にされた子ビュー1404のレイアウトパラメータを設定する *他の構成を省略* app:割合=""70%”"> / / Sets the horizontal percentage of a child view 1404 that is nested within another child view 1401, or does not set the horizontal percentage of the child view because child view 1401 contains only two horizontally aligned child views <textview 子ビュー1401内に入れ子にされた子ビュー1403のレイアウトパラメータを設定する *他の構成を省略* android:text=""曲名” / "> <TextView / *Other configurations omitted* / android:text="Singer name" / > < / textview> < / hwlayout> <hwLayout / / Set the layout parameters of child view 1402 within layout container 1400 / * Other configurations are omitted * / > <ImageView / * Other configurations are omitted * / / > <ImageView / * Other configurations are omitted * / / > <ImageView / * Other configurations are omitted * / / >
[0241] The above embodiment is a solution in which a developer designs an adaptive display interface layout by setting attribute values related to the proportion capabilities of a View or ViewGroup in a layout file (e.g., an XML file). Alternatively, attribute values related to the proportion capabilities of a View or ViewGroup may be set in a Java source code file by adding a calling interface.
[0242] Table 4 shows an example of an interface that corresponds to attribute values related to the percentage capabilities of a View or ViewGroup.
[0243] [Table 4]
[0244] The meaning of the ratio capability is described in detail above. The developer may configure a layout file based on the layout design of each display interface in the application by referring to the ratio capability, another adaptive layout capability, and a basic layout capability (e.g., Android native attributes), pack the layout file, other source code and resources, etc. of the application into an installation package (e.g., an APK file), and release the installation package to the application market. The electronic device downloads the installation package from the application market and installs the application. The following describes in detail a solution for implementing an adaptive layout based on the aforementioned layout file when the electronic device runs the application.
[0245] Specifically, the mobile phone performs the measurement procedure shown in Figure 15A(1) and Figure 15A(2) for each layout container in the layout file. Specifically, this method includes the following steps.
[0246] S1501: The layout container determines that the ratio capability is enabled, and obtains layout parameters of child views in the layout container.
[0247] Based on the layout parameters of the layout container in the layout file, it is determined whether the layout container enables the percentage capability and whether the layout orientation of the layout container is horizontal or vertical. Additionally, the child views contained within the layout container and the configured percentages of the child views are obtained. If the layout orientation of the layout container is horizontal, the percentages of the child views are horizontal percentages. If the layout orientation of the layout container is vertical, the percentages of the child views are vertical percentages.
[0248] In this case, the remaining space of the layout container in the layout orientation = the width / height of the layout container - the left / right / top / bottom inner margins. Specifically, if the layout container's layout orientation is horizontal, the remaining width of the layout container = the width of the layout container - the left and right inner margins of the layout container. If the layout container's layout orientation is vertical, the remaining height of the layout container = the height of the layout container - the top and bottom inner margins of the layout container.
[0249] S1502: Determine whether the current child view percentage is greater than 0; if so, execute step S1503; or if not, execute step S1505.
[0250] S1503: Determine the dimensions of the current child view based on the layout orientation of the layout container.
[0251] Layout orientation is the orientation in which a layout container places its child views, including horizontal and vertical orientation. If the layout orientation of a layout container is horizontal, then current child view's width = percentage x layout container's width. If the layout orientation of a layout container is vertical, then current child view's height = percentage x layout container's height.
[0252] S1504: Update the remaining space of the layout container.
[0253] If the layout container's layout orientation is horizontal, then the remaining width of the layout container = width of the layout container - width of the current child view - left and right inner margins.If the layout container's layout orientation is vertical, then the remaining height of the layout container = height of the layout container - height of the current child view - top and bottom inner margins.
[0254] Next, step S1506 is executed.
[0255] S1505: It is recorded that the current child view is a child view for which no percentage is set or an invalid percentage is set.
[0256] S1506: Determine whether all child views in the layout container have been traversed; if so, execute step S1507; or if not, execute step S1510.
[0257] S1507: Determine whether the remaining space of the layout container is greater than 0; if so, execute step S1508; if not, execute step S1509.
[0258] S1508: The remaining space of the layout container is evenly allocated to child views that have no percentage set or have an invalid percentage set.
[0259] End the measurement.
[0260] S1509: Set the dimensions of child views that have no percentage set or have an invalid percentage set to 0.
[0261] End the measurement.
[0262] S1510: Determine the next child view as the current child view. Then, step S1502 is executed.
[0263] This provides a method of measuring a layout container that includes percentage-set child views and non-percentage-set child views. It can be understood that for the purpose of explanation, an example is used in which the remaining space of the layout container in the layout orientation (the total width / total height of the layout container - the left and right / top and bottom inner margins - the sum of the width / height of the percentage-set child views) is allocated equally to the non-percentage-set child views. Certainly, the manner of allocating the remaining space in the layout orientation to the non-percentage-set child views according to another rule is not limited in this embodiment of the present application.
[0264] It can be understood that when electronic devices having different screen dimensions (e.g., a mobile phone and a tablet computer) use the same layout file (including a layout container provided with a ratio capability), according to the measurement procedures of FIG. 15A(1) and FIG. 15A(2), the ultimately rendered application interface may present different layout effects.
[0265] For example, a mobile phone has a screen width of 720 pixels and a tablet computer has a screen width of 1280 pixels. Both the mobile phone and the tablet computer use the same installation package to install a music application. A layout file corresponding to a home page of the music application includes a layout container configured to display a ranking, where the layout container enables a percentage capability. The layout container includes child view 1 (configured to display a poster of ranking 1), a child layout container (configured to display information about the top three songs), and child view 2 (configured to inform the user that there are more rankings later), arranged horizontally. The percentage of child view 1 is set to 30%, the percentage of the child layout container is not set, and the percentage of child view 2 is set to 15%.
[0266] Thus, when a mobile phone performs the measurement procedures of FIG. 15A(1) and FIG. 15A(2) for a layout container configured to render a home page of a music application and display rankings, the mobile phone performs the following calculations: Layout container width=mobile phone screen width=720 pixels. In this case, child view 1 width=layout container width×child view 1 percentage=720×30%=216 pixels, child view 2 width=layout container width×child view 2 percentage=720×15%=108 pixels, and child layout container width=layout container width−sum of determined widths of child views=720−(216+108)=396 pixels. The mobile phone displays the interface 151 shown in FIG. 15B(1). The width of child view 153 in layout container 152 is 216 pixels, the width of child view 155 is 108 pixels, and the width of child layout container 154 is 396 pixels.
[0267] When a tablet computer performs the measurement steps of FIG. 15A(1) and FIG. 15A(2) on a layout container configured to render a home page of a music application and display rankings, the tablet computer performs the following calculations: Layout container width = tablet computer screen width = 1280 pixels. In this case, child view 1 width = layout container width x percentage of child view 1 = 1280 x 30% = 384 pixels, child view 2 width = layout container width x percentage of child view 2 = 1280 x 15% = 192 pixels, and child layout container width = 1280-384-192 = 704 pixels. The tablet computer displays an interface 156 shown in FIG. 15B(2). The layout container Nai The width of child view 158 is 384 pixels, the width of child view 150 is 192 pixels, and the width of child layout container 159 is 704 pixels.
[0268] FIG. 16 is another schematic diagram of an adaptive application interface layout method according to an embodiment of the present application. In the application development phase, a developer may set attributes related to percentage capabilities in a layout file, such as an XML file. For example, the developer enables percentage capabilities, sets the layout orientation of the layout container, and sets the percentage of the child view. After that, the developer packs the layout file, other application codes and resources, etc. into an installation package, and releases the installation package to an application market. Then, a user may download the installation package from the application market by using an electronic device and install the application. When the electronic device runs the application, the layout module in the electronic device parses the attributes related to percentage capabilities from the layout file to obtain attribute values related to percentage capabilities, and sends the attribute values to the percentage module in the electronic device. Then, the layout module performs measurement and starts the percentage capabilities process. In other words, the percentage module calculates parameters of related views, such as the dimensions of the views, based on the attribute values related to percentage capabilities. The layout module performs layout based on the updated parameters of the views to obtain the positions of the views on a specific display interface of the application. Finally, the electronic device may draw and display the specific display interface. In a specific example, the ratio module may perform the relevant steps of Fig. 15A(1) and Fig. 15A(2). The layout module may be a measurement module and a layout module in the native view system of the Android system. The ratio module is a newly added function module in the measurement module in the native view system of the Android system of the present application.
[0269] (3) Equalization ability When developing an application, after adding a dependency of the adaptive layout attributes package, the developer may set a layout container (i.e., ViewGroup) with equalization capabilities on the display interface. Specifically, when editing the layout file of the display interface, the developer may set attribute values related to the equalization capabilities of the ViewGroup in the layout file (e.g., an XML file), or may set attribute values related to the equalization capabilities of the ViewGroup in a Java source code file by adding a calling interface.
[0270] Table 5 shows an example of attributes related to equalization ability.
[0271] [Table 5]
[0272] It should be noted that when setting the attributes of the layout container, the developer may enable the equalization capability of the layout container through equalization capability enablement, further set the equalization type, and set the spacing threshold A and spacing threshold B. Then, when running the application and drawing each child view within the layout container, the electronic device determines the spacing between the child views based on the dimensions of the layout container and the dimensions of the child views, and draws the child views within the layout container.
[0273] The meaning of each attribute related to the equalization ability and the effect on the display of the layout container and child views will be described in detail below with reference to the accompanying drawings.
[0274] For example, the equalization capabilities may include a first type of equalization capability and a second type of equalization capability.
[0275] Equalization can be understood as the remaining space obtained by subtracting the space occupied by each child view from the available space of the layout container being allocated equally as spacing between the child views in the specified orientation. If the layout container has no inner margins set, then the available space of the layout container = the dimensions of the layout container. If the layout container has inner margins set, then the available space of the layout container = the dimensions of the layout container - the inner margin.
[0276] The first type of equalization capability described above means that no spacing needs to be allocated between the edge of the first child view that is closest to the layout container in its layout orientation and the edge of the last child view that is closest to the layout container in its layout orientation.
[0277] For example, the layout orientation of the layout container is a horizontal orientation (or referred to as horizontal orientation) and a first type of equalization capability of the layout container is enabled. In some examples, if no inner margins are set on the layout container, the available width of the layout container is the width of the layout container. The positional relationship between the child views displayed in the layout container may be shown in (1) of FIG. 17. The left edge of the first child view coincides with the left edge of the layout container, the right edge of the last child view in the layout container coincides with the right edge of the layout container, and the spacing between adjacent child views is equal or substantially equal. In some other examples, the layout container is enabled with an inner margin in the layout orientation, e.g., a left inner margin. N and right inner merge NIn this case, available width of layout container=width of layout container-left inner margin-right inner margin. Therefore, the positional relationship between child views displayed in a layout container may be shown in (2) of FIG. 17. The distance between the left edge of the first child view and the left edge of the layout container is equal to the left inner margin of the layout container, the distance between the right edge of the last child view in the layout container and the right edge of the layout container is equal to the right inner margin of the layout container, and the spacing between adjacent child views is equal or substantially equal.
[0278] As another example, the layout orientation of the layout container is vertically oriented (or referred to as vertical orientation), and the first type of equalization capability of the layout container is enabled. In some examples, if no inner margin is set in the layout container, the available height of the layout container is the height of the layout container. The positional relationship between the child views displayed in the layout container may be shown in (1) of FIG. 18. The top edge of the first child view coincides with the top edge of the layout container, the bottom edge of the last child view in the layout container coincides with the bottom edge of the layout container, and the spacing between adjacent child views is equal or substantially equal. In some other examples, the layout container sets inner margins in the layout orientation, for example, a top inner margin (or referred to as a top inner margin or top inner margin) and a bottom inner margin (or referred to as a bottom inner margin or bottom inner margin). In this case, the available height of the layout container=the height of the layout container-top inner margin-bottom inner margin. Thus, the positional relationship between the child views displayed in the layout container may be shown in (2) of FIG. 18. The distance between the top edge of the first child view and the top edge of the layout container is equal to the top inner margin of the layout container, the distance between the bottom edge of the last child view in the layout container and the bottom edge of the layout container is equal to the bottom inner margin of the layout container, and the spacing between adjacent child views is equal or substantially equal.
[0279] The second type of equalization capability described above means that spacing needs to be allocated between the edge of the first child view that is closest to the layout container in its layout orientation and the edge of the last child view that is closest to the layout container in its layout orientation.
[0280] For example, the layout orientation of the layout container is horizontal, and the second type of equalization capability of the layout container is enabled. In some examples, when no inner margin is set in the layout container, the available width of the layout container is the width of the layout container. The positional relationship between the child views displayed in the layout container may be shown in (3) of FIG. 17. The spacing between the left edge of the first child view and the left edge of the layout container, the spacing between the right edge of the last child view in the layout container and the right edge of the layout container, and the spacing between adjacent child views are equal or substantially equal. In some other examples, the layout container sets inner margins in the layout orientation, for example, a left inner margin and a right inner margin. In this case, the available width of the layout container=the width of the layout container-the left inner margin-the right inner margin. Thus, the positional relationship between the child views displayed in the layout container may be shown in (4) of FIG. 17. The horizontal spacing between adjacent child views is equal or substantially equal, each of which is shown as spacing C. In addition, the distance between the left edge of the first child view and the left edge of the layout container is equal to the sum of the layout container's left inner margin and spacing C, and the distance between the right edge of the last child view in the layout container and the right edge of the layout container is equal to the sum of the layout container's right inner margin and spacing C.
[0281] As another example, the layout orientation of the layout container is vertical orientation, and the second type of equalization capability of the layout container is enabled. In some examples, when no inner margin is set in the layout container, the available height of the layout container is the height of the layout container. The positional relationship between the child views displayed in the layout container may be shown in (3) of FIG. 18. The distance between the top edge of the first child view and the top edge of the layout container, the distance between the bottom edge of the last child view in the layout container and the bottom edge of the layout container, and the spacing between adjacent child views are equal or substantially equal. In some other examples, the layout container sets inner margins in the layout orientation, for example, a top inner margin and a bottom inner margin. In this case, the available height of the layout container = the height of the layout container - the top inner margin - the bottom inner margin. Thus, the positional relationship between the child views displayed in the layout container may be shown in (4) of FIG. 18. The vertical spacing between adjacent child views is equal or substantially equal, each shown as spacing D. In addition, the distance between the top edge of the first child view and the top edge of the layout container is equal to the sum of the layout container's top inner margin and a gap D, and the distance between the bottom edge of the last child view in the layout container and the bottom edge of the layout container is equal to the sum of the layout container's bottom inner margin and a gap D.
[0282] In a particular implementation, an equalization capability may be set for a layout container that includes multiple identical or similar child views. The child views are, for example, a text view, a button view, an image view, or an icon button view. When the width or height of the layout container changes, the spacing between the child views may automatically and adaptively change based on the width or height of the layout container, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the equalization capability in the present solution can enable electronic devices with different screen parameters to present different display effects based on the same layout setting, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0283] In some other embodiments, a spacing threshold A or spacing threshold B may be further set for a layout container with equalization capability enabled to limit the range of the adjusted spacing between child views: The adjusted spacing between child views is less than or equal to spacing threshold A. The adjusted spacing between child views is greater than or equal to spacing threshold B.
[0284] For example, an example is used for illustration purposes in which the layout orientation of the layout container is horizontal and the first type of equalization capability is enabled. According to the aforementioned method, the spacing between the child views is determined as the spacing E based on the available space of the layout container and the dimensions of each child view. Then, the spacing E is compared with the spacing threshold A. If the spacing E is greater than the spacing threshold A, the spacing between the adjacent child views is determined as the spacing threshold A, and the spacing between the left edge of the first child view and the left edge of the layout container is adjusted, and / or the spacing between the right edge of the last child view and the right edge of the layout container is adjusted.
[0285] For example, as shown in FIG. 19(1), the layout container determines the spacing between the child views as spacing E based on the available space of the layout container and the dimensions of the child views. In this case, the spacing E is greater than the spacing threshold A. In one example, as shown in FIG. 19(2), the spacing between the child views is determined to be equal to the spacing threshold A, and all child views are centered (i.e., centered horizontally) within the layout container as a whole. In this case, the spacing between the left edge of the first child view and the left edge of the layout container is increased, and the spacing between the right edge of the last child view and the right edge of the layout container is increased. In another example, as shown in FIG. 19(3), the spacing between the child views is determined to be equal to the spacing threshold A, and all child views are left-justified within the layout container as a whole. In this case, only the spacing between the right edge of the last child view and the right edge of the layout container is increased. In yet another example, as shown in FIG. 19(4), the spacing between the child views is determined to be equal to the spacing threshold A, and all child views are right-justified within the layout container as a whole. In this case, only the distance between the left edge of the first child view and the left edge of the layout container is increased.
[0286] If the layout orientation of the layout container is horizontal and the second type of equalization capability is enabled, when it is determined that the spacing between adjacent child views is greater than the distance threshold A, an adjustment may also be performed by using the same method as for enabling the first type of equalization capability.
[0287] When the layout orientation of the layout container is vertical orientation and the equalization capability (including the first type equalization capability and the second type equalization capability) is enabled, when the spacing between adjacent child views is determined to be greater than the distance threshold A, the spacing between adjacent child views is still determined as the spacing threshold A, and the spacing between the top edge of the first child view and the top edge of the layout container is adjusted, and / or the spacing between the bottom edge of the last child view and the bottom edge of the layout container is adjusted. The child views in the layout container may be center-aligned (i.e., center-aligned vertically), top-aligned, or bottom-aligned. For details, please refer to the description when the layout orientation is horizontal orientation. Details will not be described again in this specification.
[0288] As another example, an example in which the layout orientation of the layout container is horizontal and the first type of equalization capability is enabled is used for illustration. According to the aforementioned method, the spacing between the child views is determined as spacing E based on the available space of the layout container and the dimensions of each child view. Then, the spacing E is compared with the spacing threshold B. If the spacing E is less than the spacing threshold B, the spacing between the adjacent child views is determined as spacing threshold B. In this case, the first child view and / or the last child view displays partial content. For example, if the child view is center-aligned, the left part of the first child view and the right part of the last child view may be truncated and not displayed. If the child view is left-aligned, the child view positioned on the right may be truncated and not displayed. If the child view is right-aligned, the child view positioned on the left may be truncated and not displayed.
[0289] In some other embodiments, the layout container may further set a hiding capability. Thus, if the layout container still cannot display all child views after the spacing E is adjusted to the spacing threshold B, the hiding capability may be triggered. After the hiding capability is triggered, the hidden child views may be determined based on the hiding priorities of the child views, i.e., the number of child views displayed in the layout container is reduced. In this case, the spacing between adjacent child views is re-determined based on the adjusted number of child views and the available space of the layout container.
[0290] It should be noted that the spacing between child views is first divided based on the equalization ability. If the divided spacing between child views is less than the spacing threshold B, the concealment ability is triggered, and then the spacing between the displayed child views is determined by using the equalization ability. In some other examples, the child views to be concealed may be first determined based on the concealment ability, and then the spacing between the displayed child views is determined based on the equalization ability. This is not particularly limited in this embodiment of the present application.
[0291] In some other embodiments, the layout container may further set a wrapping capability. Thus, if the layout container still cannot display all child views after the spacing E is adjusted to the spacing threshold B, the wrapping capability may be triggered. After the wrapping capability is triggered, the number of rows or columns in which the layout container displays these child views and the number of child views to be displayed in each row or column may be first determined. In this case, the layout container may determine the spacing between the child views in each row or column based on the number of child views to be displayed in each row or column and the dimensions of the child views.
[0292] It should be noted that the spacing between child views is first divided based on the equalization capability. If the divided spacing between child views is less than the spacing threshold B, the wrapping capability is triggered, and then the spacing between child views displayed in each row or each column is determined by using the equalization capability. In some other examples, the number of rows or the number of columns included in the layout container may be first determined based on the wrapping capability, and then the spacing between child views in each row is determined based on the equalization capability. This is not particularly limited in this embodiment of the present application.
[0293] In the above, an example in which the layout orientation of the layout container is horizontal and the first type of equalization capability is enabled is used for illustration. When the layout orientation of the layout container is horizontal and the second type of equalization capability is enabled, or when the layout orientation of the layout container is vertical and the equalization capability (including the first type of equalization capability and the second type of equalization capability) is enabled, by using a similar method, when it is determined that the interval between adjacent child views is less than the distance threshold B, the adjustment may also be performed.
[0294] The above embodiment is described by using an example where the dimensions of child views contained in a layout container are the same. In this application, the dimensions of child views in a layout container with equalization capability enabled are not limited, and the dimensions of child views may be the same or different.
[0295] In addition, as described above, after the equalization capability is enabled, the spacing between adjacent child views in a layout container may be equal, substantially equal, or different. For example, the allocation may be performed by using different rules. The following provides some examples.
[0296] For example, as shown in (1) of FIG. 20, the intervals between adjacent child views are in ascending order. Interval 1 < Interval 2 < Interval 3. Alternatively, as shown in (2) of FIG. 20, the intervals between adjacent child views are in descending order. Interval 1 > Interval 2 > Interval 3. Alternatively, as shown in (3) of FIG. 20, the intervals between adjacent child views change alternately. Interval 4 < Interval 5.
[0297] The following provides an example of a layout file (XML file). A layout container with equalization ability enabled is set in the layout file, and the layout container includes four child views, namely, four image views. <hwLayout xmlns:android=“http: / / schemas.android.com / apk / res / android” xmlns:app=“http: / / schemas.android.com / apk / res-auto” android:layout_height=“match_parent” android:layout_width=“match_parent” / * Other configurations are omitted * / android:orientation=“horizontal” / / Set the layout orientation of the layout container app:equalizationAbilityEnabled=“true” / / Enable the equalization ability app:equalizationAbilityType=“First Type”> / / Set the equalization ability as the first type of equalization ability <ImageView / / Child view 1 in the layout container / * Other configurations are omitted * / / > <ImageView / / Child view 2 in the layout container / * Other configurations are omitted * / / > <ImageView / / Child view 3 in the layout container / * Other configurations are omitted * / / > <ImageView / / Child view 4 in the layout container / * Other configurations are omitted * / / >
[0298] The above embodiment is a solution for a developer to design an adaptive display interface layout by setting attribute values related to the equalization capabilities of a layout container in a layout file (e.g., an XML file). Alternatively, the attribute values related to the equalization capabilities of a layout container may be set in a Java source code file by adding a calling interface.
[0299] Table 6 shows an example of an interface that corresponds to attribute values related to the equalization capabilities of a layout container.
[0300] [Table 6]
[0301] The meaning of the equalization capability is described in detail above. The developer may refer to the equalization capability, another adaptive layout capability, and the basic layout capability (e.g., Android native attributes) to configure a layout file based on the layout design of each display interface in the application, pack the layout file, other source code and resources, etc. of the application into an installation package (e.g., an APK file), and release the installation package to the application market. The electronic device downloads the installation package from the application market and installs the application. The following describes in detail a solution for implementing an adaptive layout based on the aforementioned layout file when the electronic device runs the application.
[0302] Specifically, the mobile phone executes the measurement procedure shown in Fig. 21A for each layout container in the layout file. The method specifically includes the following steps.
[0303] S2100: Layout parameters of the layout container are obtained.
[0304] The layout parameters of the layout container include whether the layout container enables equalization capability, the child views contained within the layout container, and the layout parameters of the child views. If the equalization capability is enabled, the layout parameters of the layout container further include an equalization type, a spacing threshold A, a spacing threshold B, etc. After it is determined that the layout container enables equalization capability, the following steps are performed.
[0305] S2101: Measure the dimensions of each child view in the layout container in the layout orientation.
[0306] For example, the dimensions of a child view, including its dimensions in the layout orientation, are first obtained by using the Android native measurement methods and the child view's layout parameters.
[0307] S2102: Determine whether the layout container has multiple rows / columns; if so, execute step S2104; or if not, execute step S2103.
[0308] In some cases, the layout container further enables wrapping capabilities. In this case, the number of rows or columns to be contained within the layout container and the number of child views to be contained in each row or column must first be determined based on the attributes related to the wrapping capabilities. For the spacing value between child views in each row or column, if the layout container does not enable wrapping capabilities, the layout container contains one row or one column of child views and the spacing between the child views in the row or column is calculated.
[0309] S2103: Determine the spacing E between child views in the layout container based on the equalization type.
[0310] For example, the spacing E between child views is determined based on the equalization type, the dimensions of the layout container, the inner margins, the layout orientation, and the dimensions of the child views. Adjacent child views have equal spacing E.
[0311] For the first type of equalization, the spacing E = [layout container's dimension space in layout orientation - inner margin in layout orientation - Σ(w1, w2, ..., wN)] / (N-1). For the second type of equalization, the spacing E = [layout container's dimension space in layout orientation - inner margin in layout orientation - Σ(w1, w2, ..., wN)] / (N+1).
[0312] A layout container contains N child views, where Wi is the dimension of the i-th child view in the layout direction, i=1, 2, ..., or N, where N is an integer greater than one.
[0313] Then, step S2105 is executed.
[0314] S2104: Based on the equalization type, calculate the spacing E between child views in each row / column.
[0315] The interval E is calculated based on the number of child views in each row / column and the dimensions of the child views. For a specific calculation method, see the description of step S2103.
[0316] S2105: Determine whether the interval E is greater than the interval threshold A; if so, execute step S2106; if not, execute step S2107.
[0317] S2106: Determine that the spacing between adjacent child views is equal to the spacing threshold A.
[0318] S2107: Determine whether the interval E is less than the interval threshold B; if so, execute step S2108; if not, execute step S2109.
[0319] S2108: Determine that the spacing between adjacent child views is equal to the spacing threshold B.
[0320] S2109: Determine the position of each child view within the layout container.
[0321] After the spacing between adjacent child views has been determined, all of the child views are centered, left, right, top, or bottom justified within the layout container as a whole to determine the position of each child view.
[0322] It should be noted that when the spacing between adjacent child views is adjusted based on the spacing threshold A or the spacing threshold B, if all child views are center-aligned, left-aligned, right-aligned, top-aligned, or bottom-aligned as a whole within the layout container, the distance between each outer edge of each of the child views on both sides and the layout container may need to be further adjusted. For the specific adjustment process, please refer to the related content of FIG. 19. The details will not be described again in this specification.
[0323] Note that if the first row has only one child view, the child view may be centered. If the first row has multiple child views, the multiple child views are displayed based on the equalization type.
[0324] If the first row has only one child view and the second row starts to have multiple child views, the display starts from the second row based on the equalization type. The third row and subsequent rows may be displayed based on the interval calculated in the second row. In this way, starting from the second row, each child view may present a mesh effect. Alternatively, in some other examples, the interval between adjacent child views is calculated independently based on the data of the child views included in each row and the width (or height) of each child view in the third row and subsequent rows, and the display is performed based on the calculated interval.
[0325] It can be seen that when electronic devices having different screen dimensions (e.g., a mobile phone and a tablet computer) use the same layout file (including a layout container with equalization capabilities), according to the measurement procedure of FIG. 21A, the ultimately rendered application interface may present different layout effects.
[0326] For example, a mobile phone has a screen width of 720 pixels and a tablet computer has a screen width of 1280 pixels. Both the mobile phone and the tablet computer use the same installation package to install a gallery application. A layout file corresponding to a page of the gallery application includes a layout container configured to display navigation, where the layout container enables a second type of equalization capability. The layout container includes four horizontally arranged child views, which are "Photos", "Albums", "Moments", and "Discoveries", respectively. The four child views have equal widths, 80 pixels each. The inner margin of the layout container is set to 0 pixels.
[0327] Thus, when the mobile phone renders a page of the gallery application and performs the measurement procedure of Figure 21A on the layout container, the mobile phone calculates the spacing between child views:Spacing Between Child Views = [Layout Container's Dimension Space in Layout Orientation - Inner Margin in Orientation Direction - Σ(w1, w2, ..., wN)] / (N+1) = (720-0-80 x 4) / 5 = 80 pixels. The mobile phone displays the interface 211 shown in Figure 21B(1) and the spacing between child views in the layout container 212 is 80 pixels.
[0328] When the tablet computer renders a page of the gallery application and performs the measurement procedure of Figure 21A on the layout container, the tablet computer calculates the spacing between child views:Spacing Between Child Views = [Layout Container's Dimension Space in Layout Orientation - Inner Margin in Orientation Direction - Σ(w1, w2, ..., wN)] / (N+1) = (1280-0-80 x 4) / 5 = 192 pixels. The tablet computer displays the interface 213 shown in Figure 21B(2), and the spacing between the child views in the layout container 214 is 192 pixels.
[0329] FIG. 22 is another schematic diagram of an adaptive application interface layout method according to an embodiment of the present application. In the application development phase, a developer may set attributes related to equalization capabilities in a layout file, such as an XML file. For example, the developer enables equalization capabilities, sets an equalization type, and sets an interval threshold A and an interval threshold B. After that, the developer packs the layout file, other application codes and resources, etc. into an installation package, and releases the installation package to an application market. Then, a user may download the installation package from the application market by using an electronic device and install the application. When the electronic device runs the application, the layout module in the electronic device parses attributes related to equalization capabilities from the layout file to obtain attribute values related to equalization capabilities, and sends the attribute values to the equalization module in the electronic device. Then, the layout module performs measurement and starts the equalization capabilities process. In other words, the equalization module calculates parameters of related views, such as the dimensions of the views, based on the attribute values related to equalization capabilities. The layout module performs layout based on the updated parameters of the views to obtain the positions of the views on a specific display interface of the application. Finally, the electronic device may draw and display the specific display interface. In a specific example, the equalization module may perform the relevant steps of Fig. 21A. The layout module may be the measurement module and the layout module in the native view system of the Android system. The equalization module is a newly added function module in the measurement module in the native view system of the Android system of the present application.
[0330] (4) Concealment When developing an application, after adding a dependency of the adaptive layout attributes package, the developer may set a layout container (i.e., ViewGroup) with hiding capability on the display interface. Specifically, when editing the layout file of the display interface, the developer may set the attribute value related to the hiding capability of the ViewGroup in the layout file (e.g., an XML file), or may set the attribute value related to the hiding capability of the ViewGroup in a Java source code file by adding a calling interface.
[0331] Table 7 shows some examples of attributes related to concealment ability.
[0332] [Table 7]
[0333] It should be noted that when setting the attributes of the layout container, the developer may enable the horizontal hiding capability / vertical hiding capability of the layout container through horizontal hiding capability enable / vertical hiding capability enable. In addition, hiding priority may be further set for the child views (Views or ViewGroups in the layout container). Then, when running the application and drawing the child views into the layout container, if the electronic device determines that all the child views cannot be displayed horizontally / vertically based on the dimensions of the layout container, the electronic device may determine the child views to be hidden or displayed based on the hiding priority of each child view. The electronic device then draws each child view into the layout container to implement an adaptive layout on the electronic device.
[0334] It should be further noted that the attributes in Table 7 are merely examples. In some other embodiments, the hiding ability enablement and hiding priority may also be set. In this way, after the hiding ability of the layout container is enabled, the child view to be hidden may be determined by default in the layout direction of the layout container based on the hiding priority of the child view. Optionally, the orientation of the hiding ability may be further set. After the user sets the orientation of the hiding ability, the child view to be hidden is determined in the specified orientation based on the hiding priority of the child view. This is not limited in this embodiment of the present application.
[0335] Hereinafter, by using Table 7 as an example, the meaning of each attribute related to the hiding ability and the effect on the display of the layout container and child views will be described in detail with reference to the accompanying drawings.
[0336] In some embodiments, the horizontal hiding capability of the layout container may be enabled, and a horizontal hiding priority or a horizontal display priority is set for each child view in the layout container. In this specification, the horizontal hiding priority is used as an example for explanation. Thus, after the width of the layout container is determined, it is determined whether the layout container can display all child views based on the widths of the child views arranged horizontally in the layout container. If so, all child views are displayed. If not, the child views that are hidden, i.e., the child views that are not displayed in the layout container, are further determined based on the horizontal hiding priority of each child view. In some examples, when the application is executed, the electronic device does not draw the child views that are determined to be hidden in the layout container, or draws only the child views that are determined to be displayed in the layout container. It is further noted that in this application, displaying a child view means fully displaying the content of the child view, i.e., displaying all the content of the child view.
[0337] For example, a layout container is configured to include six horizontally arranged child views, namely child view A through child view F. In addition, the six child views are arranged in order of decreasing horizontal hiding priority: (child view A, child view B, and child view D) < (child view E and child view F) < child view C. Child view A, child view B, and child view D have the same horizontal hiding priority, and child view E and child view F have the same horizontal hiding priority.
[0338] FIG. 23(1) is an effect diagram of a layout container displayed by the electronic device 1. In this case, the available width of the layout container displayed by the electronic device 1 is the sum of the widths of all child views in the layout container. In this specification, the available width of the layout container=the total width of the layout container-the left and right inner margins. FIG. 23(1) uses an example in which the left and right inner margins are 0 for illustration. Therefore, the layout container on the electronic device 1 may display all child views (child view A to child view F) horizontally.
[0339] It should be noted that if the spacing between adjacent child views is further set, the sum of the widths of all child views in the layout container includes the width of each child view and the spacing between adjacent child views. Similarly, in the following, if it is determined whether multiple child views can be arranged, the sum of the widths of the multiple child views includes the spacing between adjacent child views in the multiple child views. This will not be specifically described below. Adjacent child views may have the same spacing or different spacing. In some examples, the spacing between adjacent child views may be a fixed value set in the layout file. In some other examples, the initial value of the spacing between adjacent child views may alternatively be set in the layout container. After the child views to be hidden or displayed in the layout container are determined based on the initial value of the spacing between adjacent child views and the width of each child view, the spacing between adjacent child views is adjusted based on the width of the layout container and the width of the displayed child view. This is not limited in this embodiment of the present application.
[0340] If the layout container's available width < the sum of the widths of all child views in the layout container, it is determined that the layout container cannot display all its child views. In this case, it determines which child views will be hidden or displayed based on the layout container's available space, the width of each child view, and the horizontal hiding priority of each child view.
[0341] In the technical solution, if a layout container cannot display all child views, child views with higher horizontal hiding priority in the layout container are hidden preferentially in the horizontal hiding priority order of the child views.
[0342] 23(2) is an effect diagram of a layout container displayed by electronic device 2. Because the available width of the layout container displayed by electronic device 2 is less than the sum of the widths of the child views in the layout container, the child view with the highest horizontal hiding priority in the layout container (e.g., child view C) is hidden preferentially. After child view C is hidden, the layout container on electronic device 2 can display the other five child views, namely, child view A, child view B, and child view D to child view F.
[0343] As another example, (3) in FIG. 23 is an effect diagram of a layout container displayed by the electronic device 3. Because the available width of the layout container displayed by the electronic device 3 is less than the sum of the widths of the child views in the layout container, the child view with the highest horizontal hiding priority in the layout container (e.g., child view C) is preferentially hidden. Then, based on the widths of the other child views (e.g., child view A, child view B, and child view D to child view F), it is determined that the layout container cannot yet display all five child views. Furthermore, it is further determined that the child views with the next highest horizontal hiding priority in the layout container after child view C (e.g., child view E and child view F) are hidden. Then, based on the widths of the other child views (child view A, child view B, and child view D), it is determined that the layout container can display all three child views. In this case, the electronic device 3 displays the three child views.
[0344] It should be noted that in some examples, multiple child views with the same horizontal hiding priority are hidden or displayed at the same time. For example, child view E and child view F are child views with the same horizontal hiding priority. In this case, child view E and child view F are displayed in the layout container at the same time or are not displayed in the layout container at the same time. In some other examples, it may be determined that, instead, in multiple child views with the same horizontal hiding priority, a child view arranged after the current child view is hidden preferentially. For example, child view E and child view F are child views with the same horizontal hiding priority. If it is determined to hide a child view, child view F is hidden before child view E. In other words, if it is determined that the electronic device 3 cannot display all five child views (child view A, child view B, and child view D to child view F), it is further determined to hide child view F. In this case, it is determined whether the layout container can display all other child views (child view A, child view B, child view D, and child view E). If it is determined that four child views can be displayed, the layout container displays the four child views, as shown in (4) of Fig. 23. Indeed, for child views with the same horizontal hiding priority, the child view that is preferentially hidden may be determined by using another method or may be determined randomly, which is not limited in this embodiment of the present application.
[0345] It should be noted that the arrangement order of the child views herein may be determined based on the user's text reading habits. For example, the user's reading habits may be specifically determined based on the language of the text displayed in the child views. Generally, for languages such as Chinese and English, users are accustomed to reading from left to right and from top to bottom. Thus, for multiple horizontally arranged child views, the left child view may be considered to be arranged before the right child view, and for multiple vertically arranged child views, the top child view may be considered to be arranged before the bottom child view. For some other languages, for multiple horizontally arranged child views, the bottom child view may be considered to be arranged before the left child view, and for multiple vertically arranged child views, the bottom child view may be considered to be arranged before the top child view. Furthermore, the user may alternatively set whether multiple horizontally arranged child views are arranged on the left or right side first, and / or whether multiple vertically arranged child views are arranged on the top or bottom side first. The aforementioned arrangement order of the child views is merely an example and is not limited in this application.
[0346] In another technical solution, if a layout container cannot display all child views, the child views that may be displayed in the layout container are calculated sequentially in the order of the horizontal hiding priorities of the child views.
[0347] Specifically, the child views to be determined whether to be displayed by each calculation are determined in ascending order of the horizontal hiding priority of the child views, and the child views are referred to as the determined child views for short. The horizontal hiding priority of the determined child views in each calculation is the same. In each calculation process, if the available width of the layout container - the sum of the widths of the child views determined to be displayed ≥ the sum of the widths of the determined child views in the current calculation, it is determined that the layout container can display the determined child view in the current calculation. If it is determined that the available width of the layout container < the sum of the widths of the determined child views in the current calculation, it is determined that the layout container cannot display the determined child view in the current calculation.
[0348] In addition, if the available width of the layout container - the sum of the widths of the determined child views to be displayed > the sum of the widths of the child views to be determined in the current calculation, it needs to be further determined whether another child view can be placed in the layout container: another child view with a higher horizontal hiding priority than the current child view to be determined is determined as the child view to be determined in the next calculation.
[0349] If the layout container's available width - the sum of the widths of the child views determined to be displayed = the sum of the widths of the child views determined in the current calculation, this indicates that the layout container cannot display more child views than the child views determined in the current calculation.
[0350] The following provides a specific description with reference to an example. For ease of explanation, w(M) is used to identify the width of child view M, where M is a variable. For example, w(A) denotes the width of child view A.
[0351] For example, as shown in FIG. 23(2), the available width of the layout container displayed by the electronic device 2<the sum of the widths of the child views in the layout container.
[0352] First, it is determined that the child views (e.g., child view A, child view B, and child view D) in the layout container with the lowest horizontal hiding priority (or highest horizontal display priority) are the child views to be displayed first and are the child views to be determined in the current calculation. Since the available space of the layout container of the electronic device 2 > Σ[w(A), w(B), w(D)], it is determined that child view A, child view B, and child view D can be displayed in the layout container. In addition, it needs to be further determined whether another child view can be displayed.
[0353] Note that if it is determined that the available width of a layout container = Σ[w(A), w(B), w(D)], then only child view A, child view B, and child view D can be displayed within the layout container.
[0354] Furthermore, another child view with a slightly higher horizontal obscuring priority (e.g., child view E and child view F) is determined to be the child view to be determined in the current calculation. If it is determined that the available width of the layout container-Σ[w(A),w(B),w(D)]≧Σ[w(E),w(F)], it is determined that child view E and child view F may further be displayed within the layout container. In this case, it needs to be further determined whether another child view may be displayed if the available width of the layout container-Σ[w(A),w(B),w(D)]>Σ[w(E),w(F)].
[0355] Note that if it is determined that the available width of the layout container - Σ[w(A),w(B),w(D)] = Σ[w(E),w(F)], then only child view A, child view B, child view D, child view E, and child view F can be displayed within the layout container.
[0356] Furthermore, it is determined whether another child view with a higher horizontal concealment priority (e.g., child view C) can be displayed within the layout container. In this case, the available width of the layout container - Σ[w(A), w(B), w(D), w(E), w(F)] < w(C), and child view C cannot be displayed within the layout container.
[0357] In conclusion, the layout container of the electronic device 2 displays a total of five child views, namely, child view A, child view B, and child views D to F.
[0358] As another example, as shown in (2) of FIG. 23, the available width of the layout container displayed by the electronic device 2 < the sum of the widths of the child views within the layout container.
[0359] First, the child views with the lowest horizontal concealment priority within the layout container (e.g., child view A, child view B, and child view D) are determined to be the first child views to be displayed and the child views to be determined in the current calculation. Since the available space of the layout container of the electronic device 2 > Σ[w(A), w(B), w(D)], it is determined that child view A, child view B, and child view D can be displayed within the layout container. In addition, it is necessary to further determine whether another child view can be displayed.
[0360] Furthermore, another child view with a slightly higher horizontal concealment priority (e.g., child view E and child view F) is determined to be the child view to be determined in the current calculation. If it is determined that the available width of the layout container - Σ[w(A), w(B), w(D)] < Σ[w(E), w(F)], it is determined that child view E and child view F cannot be displayed within the layout container. In this case, only child view A, child view B, and child view D are displayed within the layout container.
[0361] In some other embodiments, the vertical hiding capability of the layout container may be enabled, and a vertical hiding priority or a vertical display priority is set for each child view in the layout container. Thus, after the height of the layout container is determined, it is determined whether the layout container can display all child views based on the heights of the child views arranged vertically in the layout container. If so, all child views are displayed. If not, the child views that are hidden, i.e., the child views that are not displayed in the layout container, are further determined based on the vertical hiding priority of each child view. For a specific implementation form of the vertical hiding capability, please refer to the related content of the horizontal hiding capability. Details will not be described again in this specification.
[0362] In a particular implementation, a hiding capability may be set for a layout container that includes multiple child views. The child views are, for example, a text view, a button view, an image view, or an icon button view (ImageButton View). When the width or height of the layout container changes, some child views in the layout container may be automatically determined to be hidden, so as to meet the display requirements of electronic devices with different screen dimensions. It can be found that the hiding capability in the present solution can enable electronic devices with different screen parameters to present different display effects based on the same layout setting, reduce the development and maintenance workload of developers, and meet the display requirements of various types of electronic devices.
[0363] Below is an example of one layout file (XML file): A layout container with hiding capability enabled is set in the layout file and the layout container contains four child views, namely, four image views. <hwLayout xmlns:android=“http: / / schemas.android.com / apk / res / android” xmlns:app="http: / / schemas.android.com / apk / res-auto" / * Omitted other configurations * / android:orientation="horizontal" app:vertical_hiding_capability_enable="true" / / Enable vertical hiding capability app:wrapping_capability_enable="true" / / Enable wrapping capability app:wrapping_alignment_mode="end"> / / Enable wrapping alignment mode. In the case of Chinese and English, "end" corresponds to right alignment <ImageView / / Set child view 1 in the layout container - ImageView / * Omitted other configurations * / app:layout_vertical_hiding_priority="5" / / Set the vertical hiding priority of child view 1 app:wrapping_reference_width="90dp" / > / / Set the wrapping reference value of wrapped child view 1 <imageview 子ビュー2をレイアウトコンテナ-画像ビュー内に設定する *他の構成を省略* app:layout_垂直隠蔽優先度=""3”" 子ビュー2の垂直隠蔽優先度を設定する app:ラッピング基準幅=""90dp” / "> / / Set wrapping criteria for wrapped child view 2 <imageview 子ビュー3をレイアウトコンテナ-画像ビュー内に設定する *他の構成を省略* app:layout_垂直隠蔽優先度=""2”" 子ビュー3の垂直隠蔽優先度を設定する app:ラッピング基準幅=""90dp” / "> / / Set wrapping criteria for wrapped child view 3 <imageview 子ビュー4をレイアウトコンテナ-画像ビュー内に設定する *他の構成を省略* app:layout_垂直隠蔽優先度=""4”" 子ビュー4の垂直隠蔽優先度を設定する app:ラッピング基準幅=""90dp” / "> / / Set wrapping criteria for wrapped child view 4 <imageview 子ビュー5をレイアウトコンテナ-画像ビュー内に設定する *他の構成を省略* app:layout_垂直隠蔽優先度=""1”" 子ビュー5の垂直隠蔽優先度を設定する app:ラッピング基準幅=""90dp” / "> / / Set wrapping criteria for wrapped child view 5
[0364] The above embodiment is a solution for a developer to design an adaptive display interface layout by setting an attribute value related to the hiding ability of a layout container in a layout file (e.g., an XML file). Alternatively, by adding a calling interface, the attribute value related to the hiding ability of a layout container may be set in a Java source code file.
[0365] Table 8 shows an example of an interface that corresponds to attribute values related to the hiding capabilities of a layout container.
[0366] [Table 8]
[0367] The meaning of the hiding capability is described in detail above. The developer may configure a layout file based on the layout design of each display interface in the application with reference to the hiding capability, another adaptive layout capability, and the basic layout capability (e.g., Android native attributes), pack the layout file, other source code and resources, etc. of the application into an installation package (e.g., APK file), and release the installation package to the application market. The electronic device downloads the installation package from the application market and installs the application. The following describes in detail a solution for implementing an adaptive layout based on the aforementioned layout file when the electronic device runs the application.
[0368] Specifically, the mobile phone performs the measurement procedure shown in Fig. 24A for each layout container in the layout file. The method specifically includes the following steps.
[0369] S2400: Layout parameters of the layout container are obtained.
[0370] The layout parameters of a layout container include whether to enable horizontal and vertical hiding capabilities, the dimensions of the layout container, inner margins, etc.
[0371] S2401: The layout container determines to enable horizontal hiding capability and retrieves all child views contained within the layout container.
[0372] In this specification, an example in which a layout container enables horizontal hiding capability is used for explanation. Each child view contained in the layout container and layout parameters corresponding to each child view are obtained. The layout parameters corresponding to each child view include attribute values of dimensions of each child view and horizontal hiding priority or horizontal display priority corresponding to each child view. In some examples, if a hiding priority is not set for a child view, the child view may be considered to be the child view with the lowest hiding priority or the child view that needs to be displayed.
[0373] S2402: Measure each child view in the layout container and store the width of each child view.
[0374] Based on each child view's layout parameters (other than the horizontal hiding priority), parameters transferred from the layout container, etc., initial measurements are performed for each child view in the layout container (e.g., measurements are performed based on Android's original measurement procedure), and the width of each child view is obtained and stored.
[0375] S2403: Determine multiple batches of child views based on the horizontal obscuring priorities of the child views, and start calculating the sum of widths of the batches of child views with the lowest horizontal obscuring priorities.
[0376] In other words, one or more child views with the same horizontal hiding priority are determined as a batch of child views. The child views to be displayed within the layout container are determined within the batch in ascending order of horizontal hiding priority. The first batch of child views is the batch of child views with the lowest horizontal hiding priority. The sum of the widths of the batch of child views is calculated.
[0377] S2404: Determine whether the available space of the layout container < the sum of the widths of the child views determined to be displayed and the current batch of child views; if so, perform step S2405; or if not, perform step S2406.
[0378] In this specification, the available space of a layout container = the width of the layout container - the left and right inner margins. When the first batch of child views is calculated, no child views are determined to be displayed.
[0379] If the available space of the layout container<the sum of the widths of the child views determined to be displayed and the current batch of child views, it indicates that the available space of the layout container cannot be used to place the current batch of child views, i.e., step S2405 is executed. If the available space of the layout container>=the sum of the widths of the child views determined to be displayed and the current batch of child views, it indicates that the available space of the layout container can be used to place the current batch of child views.
[0380] It should be noted that if the spacing between child views is further set, the spacing between the child views determined to be displayed and the spacing between the current batch of child views need to be further added during the determination.
[0381] S2405: The layout container determines not to display the current batch of child views and not to display other child views that have a higher hiding priority than the current batch of child views.
[0382] The measurement procedure is finished.
[0383] S2406: The layout container determines to display the current batch of child views.
[0384] S2407: Determine whether all batches of the child view have been traversed; if so, end the measurement procedure; otherwise, execute step S2408.
[0385] S2408: Calculate the sum of the widths of the next batch of child views that have a higher hiding priority than the current batch of child views, and then execute step S2404.
[0386] The above is explained by using an example where the horizontal hiding capability is enabled. If the vertical hiding capability is enabled, calculations and decisions need to be performed based on the height of the layout container and the height of each child view. For other contents, please refer to the related description of Figure 24A.
[0387] 24B is a schematic flowchart of another measurement method for a layout container according to an embodiment of the present application. In other words, steps S2403 to S2408 are replaced by steps S2409 to S2415. The details are as follows:
[0388] S2400: Layout parameters of the layout container are obtained.
[0389] The layout parameters of a layout container include whether to enable horizontal and vertical hiding capabilities, the dimensions of the layout container, inner margins, etc.
[0390] S2401: The layout container determines to enable horizontal hiding capability and retrieves all child views contained within the layout container.
[0391] In this specification, an example in which a layout container enables horizontal hiding capability is used for explanation. Each child view contained in the layout container and layout parameters corresponding to each child view are obtained. The layout parameters corresponding to each child view include attribute values of dimensions of each child view and horizontal hiding priority or horizontal display priority corresponding to each child view. In some examples, if a hiding priority is not set for a child view, the child view may be considered to be the child view with the lowest hiding priority or the child view that needs to be displayed.
[0392] S2402: Measure each child view in the layout container and store the width of each child view.
[0393] Based on each child view's layout parameters (other than the horizontal hiding priority), parameters transferred from the layout container, etc., initial measurements are performed for each child view in the layout container (e.g., measurements are performed based on Android's original measurement procedure), and the width of each child view is obtained and stored.
[0394] S2409: Determine whether the available space of the layout container is >= the sum of the widths of all child views; if so, execute step S2410; if not, execute step S2411.
[0395] If the spacing between the child views is further set, the total child view spacing must further be added to the right of the inequality during the determination.
[0396] S2410: Display all child views within a layout container.
[0397] The measurement procedure is finished.
[0398] S2411: Determine multiple batches of child views based on the horizontal hiding priorities of the child views, and first hide the batch of child views with the highest horizontal hiding priorities.
[0399] S2412: Determine whether the available space of the layout container is >= the sum of the widths of all child views - the sum of the widths of child views determined to be obscured; if so, perform step S2413; if not, perform step S2414.
[0400] If spacing between child views is further set, spacing between child views other than the child view determined to be occluded must further be added to the right of the inequality during the determination.
[0401] S2413: Display child views other than the child view determined to be hidden in the layout container.
[0402] End the measurement.
[0403] S2414: Determine whether all batches of child views have been traversed; if so, end the measurement procedure; otherwise, execute step S2415.
[0404] S2415: Determine the next batch of child views that have a lower horizontal obscuring priority than the current batch of child views, and then perform step S2412.
[0405] It can be understood that when electronic devices having different screen dimensions (e.g., a mobile phone and a tablet computer) use the same layout file (including a layout container with hiding capabilities), according to the measurement procedure of FIG. 24A or FIG. 24B, the application interface finally drawn may present different layout effects.
[0406] For example, the mobile phone has a screen width of 720 pixels, and the tablet computer has a screen width of 1280 pixels. Both the mobile phone and the tablet computer use the same installation package to install a music application. A layout file corresponding to a playback page of the music application includes a layout container configured to control playback, where the layout container enables hiding capabilities. The layout container includes five horizontally arranged child views, which are "Previous", "Play / Pause", "Next", "View More", and "Favorites", respectively. In addition, the hiding priority is set to be arranged in ascending order: ("Previous", "Play / Pause", and "Next") < "View More" < "Favorites". In addition, the widths of the five child views are equal to 100 pixels, and the spacing between the child views is 180 pixels. The inner margin of the layout container is set to 0 pixels.
[0407] In this case, when the mobile phone renders the playback page of the music application and executes the measurement procedure of FIG. 24A on the layout container (FIG. 24A is used as an example), the mobile phone determines that the first batch of child views to be displayed are "previous", "play / pause", and "next", and performs the following calculation: sum of widths of the three child views + sum of spacing between the three child views = 100 × 3 + 180 × 2 = 660 pixels < 720 pixels of the mobile phone's screen width. Therefore, the mobile phone decides to display the three child views. In this case, after the three child views are displayed, the remaining screen width of the mobile phone = 720 - 660 = 60 pixels. The next batch of child views is determined based on the hiding priority, i.e., "See More". If "See More" needs to be displayed again, the width that needs to be further occupied = 100 + 180 = 280 pixels > 60 pixels of the remaining screen width of the mobile phone. In this case, the mobile phone decides not to display the current batch of child views and other child views. The mobile phone displays the interface 251 shown in (1) of FIG. 25. The layout container 252 displays three child views: "Previous," "Play / Pause," and "Next."
[0408] When the tablet computer draws the playback page of the music application and executes the measurement procedure of FIG. 24A on the layout container (FIG. 24A is used as an example), the tablet computer determines by calculation that the first batch of child views to be displayed are "previous", "play / pause" and "next", and performs the following calculation: sum of widths of three child views + sum of spacing between three child views = 100 × 3 + 180 × 2 = 660 pixels < 1280 pixels of the tablet computer's screen width. Therefore, the tablet computer decides to display three child views. In this case, after the three child views are displayed, the remaining screen width of the tablet computer = 1280 - 660 = 620 pixels. The next batch of child views is determined based on the hiding priority, i.e., "See More". If "See More" needs to be displayed again, the width that needs to be occupied further = 100 + 180 = 280 pixels < 620 pixels of the remaining screen width of the tablet computer obtained after the three child views are displayed. Therefore, the tablet computer decides to display "See More" further. In this case, remaining screen width of the tablet computer=620-280=340 pixels. Then, the next batch of child views is determined based on the concealment priority, i.e., "Favorites". If "Favorites" needs to be displayed again, the width that needs to be occupied further=100+180=280 pixels<340 pixels of remaining screen width of the tablet computer. Therefore, the tablet computer decides to display "View More" further. The tablet computer displays an interface 253 shown in FIG. 25(2). A layout container 254 displays five child views, i.e., "Previous", "Play / Pause", "Next", "View More", and "Favorites".
[0409] FIG. 26 is another schematic diagram of an adaptive application interface layout method according to an embodiment of the present application. In the application development phase, a developer may set attributes related to hiding capabilities in a layout file, such as an XML file. For example, horizontal hiding capabilities or vertical hiding capabilities are enabled, and horizontal hiding priorities or vertical hiding priorities of each child view are set. After that, the developer packs the layout file, other application codes and resources, etc. into an installation package, and releases the installation package to an application market. Then, a user may download the installation package from the application market by using an electronic device, and install the application. When the electronic device runs the application, the layout module in the electronic device parses attributes related to hiding capabilities from the layout file to obtain attribute values related to hiding capabilities, and sends the attribute values to a hiding module in the electronic device. Then, the layout module performs measurement and starts a hiding capability process. In other words, the hiding module calculates parameters of related views, such as dimensions of the views, based on the attribute values related to hiding capabilities. The layout module performs layout based on the updated parameters of the views to obtain the positions of the views on a specific display interface of the application. Finally, the electronic device may draw and display a specific display interface. In a specific example, the concealment module may execute the relevant steps of FIG. 24A. The layout module may be the measurement module and the layout module in the native view system of the Android system. The concealment module is a newly added function module in the measurement module in the native view system of the Android system of the present application.
[0410] (5) Extension ability When developing an application, after adding a dependency of the adaptive layout attributes package, the developer may set a ViewGroup with stretch capability on the display interface. Specifically, when editing the layout file of the display interface, the developer may set an attribute value related to the stretch capability of the ViewGroup in the layout file (e.g., an XML file), or may set an attribute value related to the stretch capability of the ViewGroup in a Java source code file by adding a calling interface.
[0411] Table 9 shows an example of attributes related to stretching capabilities.
[0412] [Table 9]
[0413] Note that when setting the layout container's attributes, a developer may enable the layout container's stretch capability through stretch capability enable. Then, for any child views contained within the layout container (i.e., Views or ViewGroups contained within the layout container), the child view's width is set to "match_parent" and / or the child view's height is set to "match_parent". Thereafter, when running the application and drawing the child views, the electronic device stretches the child views based on the dimensions of the layout container.
[0414] For example, if the layout container is set to have horizontal stretch capability, and if the dimensions of the layout container on the electronic device are 720×1080 pixels, the dimensions of the child view may be 720×600 pixels. If the dimensions of the layout container on the electronic device are 1280×800 pixels, the dimensions of the child view may be 1280×600 pixels. In another example, the layout container is set to have horizontal stretch capability, and both the left inner margin and the right inner margin are set to 10 pixels. If the dimensions of the layout container on the electronic device are 720×1080 pixels, the dimensions of the child view may be 700×600 pixels. If the dimensions of the layout container on the electronic device are 1280×800 pixels, the dimensions of the child view may be 1260×600 pixels.
[0415] The meaning of each attribute related to the stretch ability and the effect on the display of the layout container and child views will be described in detail below with reference to the accompanying drawings.
[0416] In some embodiments, a developer may set a layout container's horizontal stretch enable to enabled, or may set a layout container's vertical stretch enable to enabled, or may set a layout container's horizontal stretch enable and vertical stretch enable to enabled.
[0417] For example, in the interface shown in Figure 27(1), a child view completely occupies a layout container. After the stretch capability of a layout container is enabled, when the dimensions of the layout container change, the child view within the layout container is stretched in the specified direction.
[0418] In some examples, the attribute value of the layout container's horizontal stretch capability enable is set to true, and the width of the child view is set to "match_parent". In this case, when the dimensions of the layout container change, the child view stretches horizontally. In other words, the width of the child view adaptively changes according to the width of the layout container, as shown in Figure 27(2), Figure 27(3), and Figure 27(4).
[0419] It should be noted that if the height of the layout container also changes, the child view performs adjustments based on the layout parameters set by the child view. For example, if the height of the child view is a fixed value, the height of the child view remains at a fixed value. If the child view does not completely occupy the space of the layout container vertically as the height of the layout container changes, the vertical alignment scheme of the child view may be further set. The vertical alignment schemes include vertical center alignment (as shown in (2) of FIG. 27), top alignment (as shown in (3) of FIG. 27), and bottom alignment. Top alignment means that the top boundary of the child view is aligned with the top boundary of the layout container. Vertical center alignment means that the distance between the top boundary of the child view and the top boundary of the layout container is equal to the distance between the bottom boundary of the child view and the bottom boundary of the layout container. Bottom alignment means that the bottom boundary of the child view is aligned with the bottom boundary of the layout container. Indeed, the distance between the top boundary of the child view and the top boundary of the layout container (i.e., the top inner margin) may also be set. In this case, as shown in (4) of FIG. 27, when the height of the container dimension changes, the distance between the top boundary of the child view and the top boundary of the layout container remains at the specified value, and the distance between the bottom boundary of the child view and the bottom boundary of the layout container changes according to the layout container. Alternatively, the distance between the bottom boundary of the child view and the bottom boundary of the layout container (i.e., the bottom inner margin) may also be set. In this case, when the height of the container dimension changes, the distance between the bottom boundary of the child view and the bottom boundary of the layout container remains at the specified value, and the distance between the top boundary of the child view and the top boundary of the layout container changes according to the layout container.
[0420] If the child view's height is match_parent, the child view's height changes with the layout container.
[0421] In some other examples, the attribute value of the layout container's vertical stretch capability enable is set to true, and the height of the child view is set to "match_parent". In this case, when the dimensions of the layout container change, the child view is stretched vertically. In other words, the height of the child view adaptively changes according to the height of the layout container, as shown in (5) of FIG. 27, (6) of FIG. 27, and (7) of FIG. 27.
[0422] It should be noted that if the width of the layout container also changes, the child view performs adjustments based on the layout parameters set by the child view. For example, if the width of the child view is a fixed value, the width of the child view remains at a fixed value. If the child view does not completely occupy the space of the layout container horizontally as the width of the layout container changes, the horizontal alignment scheme of the child view may be further set. The horizontal alignment schemes include horizontal center alignment (as shown in (5) of FIG. 27), left alignment (as shown in (6) of FIG. 27), and right alignment. Left alignment means that the left boundary of the child view is aligned to the left boundary of the layout container. Horizontal center alignment means that the distance between the left boundary of the child view and the left boundary of the layout container is equal to the distance between the right boundary of the child view and the right boundary of the layout container. Right alignment means that the right boundary of the child view is aligned to the right boundary of the layout container. Indeed, the distance between the left boundary of the child view and the left boundary of the layout container (i.e., the left inner margin) may also be set. In this case, as shown in (7) of FIG. 27, when the width of the container dimension changes, the distance between the left boundary of the child view and the left boundary of the layout container remains at the specified value, and the distance between the right boundary of the child view and the right boundary of the layout container changes according to the layout container. Alternatively, the distance between the right boundary of the child view and the right boundary of the layout container (i.e., the right inner margin) may be set. In this case, when the width of the container dimension changes, the distance between the right boundary of the child view and the right boundary of the layout container remains at the specified value, and the distance between the left boundary of the child view and the left boundary of the layout container changes according to the layout container. As another example, if the height of the child view is match_parent, the height of the child view changes according to the layout container.
[0423] In some other examples, the attribute value of the layout container's horizontal stretch capability enable is set to true, the width of the child view is set to "match_parent", and the attribute values of the layout container's vertical stretch capability enable are set to true, and the height of the child view is set to "match_parent". In this case, when the dimensions of the layout container change, the child view is stretched horizontally and vertically. In other words, as shown in (8) of FIG. 27, the height of the child view adaptively changes according to the height of the layout container, and the width of the child view adaptively changes according to the width of the layout container.
[0424] It can be seen that based on the stretch capability provided in this embodiment of the present application, child views in a layout container with stretch capability may be adaptively stretched based on changes in the layout container. Thus, electronic devices with different screen parameters can present different display effects based on the same layout settings, reducing the development and maintenance workload of developers, and meeting the display requirements of various types of electronic devices. For example, the stretch capability may be set for a layout container in which a text view (e.g., TextView view or EditText view) and a button view (e.g., Button view or ImageButton view) are located. When the width and / or height of the layout container change, adaptive stretching may be performed in a specified direction to meet the display requirements.
[0425] In some other embodiments, after setting the stretch capability of a layout container to be valid, a developer may further set the inner margin of the layout container in the stretch direction. Thus, if the inner margin is kept from the layout container, child views within the layout container may stretch in the specified direction as the dimensions of the layout container change.
[0426] For example, as shown in (1) of Figure 28, a child view does not completely occupy a layout container. After the stretch capability of a layout container is enabled, when the dimensions of the layout container change, the child view within the layout container is stretched in the specified direction.
[0427] In some examples, the attribute value of the layout container's horizontal stretch capability enabled is set to true, and the width of the child view is set to "match_parent". The horizontal inner margins, e.g., the left inner margin and / or the right inner margin, are further set. Thus, as shown in FIG. 28(2), when the dimensions of the layout container change, the horizontal inner margins of the child view remain at the specified value, and the child view is stretched horizontally. In other words, the width of the child view changes adaptively according to the width of the layout container. Indeed, the developer may also set any horizontal inner margins. In this case, other inner margins that are not set are 0dp by default.
[0428] Please note that for the vertical change of child views, please refer to the explanation of the related content in Figure 27. The details will not be described again in this specification.
[0429] In some other examples, the layout container's vertical stretch capability enable attribute value is set to true, and the height of the child view is set to "match_parent". A vertical inner margin, e.g., a top inner margin and / or a bottom inner margin, is further set. Thus, as shown in FIG. 28(3), when the layout container's dimensions change, the vertical inner margin of the child view remains at the specified value, and the child view is stretched vertically. In other words, the child view's height will adaptively change depending on the height of the layout container. Indeed, developers may also set any vertical inner margins, in which case any other inner margins not set will default to 0dp.
[0430] Please note that for the horizontal change of child views, please refer to the explanation of the related content in Figure 27. The details will not be described again in this specification.
[0431] In some other examples, the attribute value of the layout container's horizontal stretch capability enable is set to true, the child view's width is set to "match_parent" and the horizontal inner margin is set, and the attribute values of the layout container's vertical stretch capability enable are set to true, the child view's height is set to "match_parent" and the vertical inner margin is set. In this case, when the dimensions of the layout container change, the child view stretches horizontally and vertically. In other words, as shown in (4) of FIG. 28, the height of the child view adaptively changes according to the height of the layout container, and the width of the child view adaptively changes according to the width of the layout container.
[0432] It can be seen that by setting the inner margins of a layout container, it is ensured that the views within the layout container maintain a particular distance from the edges of the layout container, so that different display requirements can be met. For example, by ensuring that the views within the layout container maintain a particular distance from the edges of the layout container, the display interface can present a magazine-like layout, e.g., present a large margin space, so that the display interface presents a magazine-like reading feel, thereby enhancing the visual experience of the user.
[0433] In some other embodiments, in addition to the stretch ability of the layout container in the specified direction and the inner margin value in the specified direction, maximum / minimum values may be further set for the dimensions of the layout container, for example, maximum width, minimum width, maximum height, and minimum height. Maximum width means the maximum value that can be reached by the sum of the horizontal widths of all child views (including the horizontal spacing between child views) in the layout container. Minimum width means the minimum value that can be reached by the sum of the horizontal widths of all child views (including the horizontal spacing between child views) in the layout container. Maximum height means the maximum value that can be reached by the sum of the vertical heights of all child views (including the vertical spacing between child views) in the layout container. Minimum height means the minimum value that can be reached by the sum of the vertical widths of all child views (including the vertical spacing between child views) in the layout container. It should be noted that in the stretch process of the child views, if the sum of the dimensions of all child views conflicts with the maximum / minimum dimension values set by the layout container, the actual stretch percentage of the child view may be determined based on the maximum / minimum dimension values. In some other examples, if the maximum / minimum dimension values of the layout container are not set, default values may also be used. For example, the maximum width is infinity by default, the minimum width is 0dp by default, the maximum height is infinity by default, and the minimum height is 0dp by default. Of course, the default values may alternatively be other values. This is not limited in this embodiment of the present application.
[0434] It can be observed that setting maximum / minimum dimension values of a layout container can prevent the views in the layout container from being stretched or shrunk excessively in the specified direction. For example, avoiding excessive stretching in the specified direction can ensure that view information in the layout container is not lost; for example, image views are not distorted or transformed. Avoiding excessive shrinking in the specified direction can ensure that view contents in the layout container are not overlapped, thus preventing the display effect from being affected.
[0435] When the child view is a View, when the application is run, it should be noted that the electronic device extends the View in the specified direction and displays the View based on the actual dimensions of the layout container, the inner margin, and the maximum / minimum dimension values of the layout container. When the view is a ViewGroup, when the application is run, the electronic device extends the ViewGroup in the specified direction by using the same method. It should be noted that for a View or ViewGroup nested within a ViewGroup, the attributes corresponding to the ViewGroup are used for the layout. For example, when the stretching ability is also enabled for the ViewGroup, the method corresponding to the stretching ability is used to draw the View or ViewGroup nested within the ViewGroup. As another example, when the stretching ability is not enabled for the ViewGroup, the method corresponding to the stretching ability is not used to draw the View or ViewGroup nested within the ViewGroup. In other words, the stretching ability set for the layout container can be applied to the child views stored within the layout container, but cannot be applied to the Views or ViewGroups nested within the child views.
[0436] The following provides an example of a layout file (XML file). A layout container with stretching ability enabled is set within the layout file, and the layout container contains one child view (a button view). / * Example of layout stretching * / <com.huawei.AdaptiveStretchingLayout xmlns:android="http: / / schemas.android.com / apk / res / android” xmlns:app="http: / / schemas.android.com / apk / res-auto” android:layout_height="300dp" / / Set the height of the layout container android:layout_width="130dp” / / Sets the width of the layout container app:Horizontal stretching capability enabled="true" / / Enables the horizontal stretching capability of the layout container app:vertical stretching capability enabled="true" / / Enables the vertical stretching capability of the layout container android:leftinnermargin="25dp" / / Sets the left inner margin of the layout container android:top-inner-margin="25dp" / / Sets the top inner margin of the layout container android:right-inner-margin="25dp" / / Sets the right inner margin of the layout container android:bottom inner margin="25dp" / / Sets the bottom inner margin of the layout container app:max-width="400dp" / / Sets the maximum width of the layout container app:max-height="400dp" / / Sets the maximum height of the layout container app:min-width="100dp” / / Sets the minimum width of the layout container app:min-height="100dp"> / / Set the minimum height of the layout container <button 子ビュー(ボタンビュー)を設定する android:layout_width=""match_parent”" 子ビューの幅を設定する android:layout_height=""match_parent”" 子ビューの高さを設定する android:text=""Button” / "> < / com.huawei.adaptive_extension_layout>
[0437] To better understand the adaptive layout effect implemented by using the extension ability in the present embodiment of the present application, in this specification, for the purpose of illustration, an example in which a head unit having different screen sizes displays a music playback interface is used. It should be noted that the layout file corresponding to the music playback interface is the same, that is, the layout parameters of the Views and ViewGroups on the music playback interface are the same.
[0438] As shown in FIG. 29(1), interface 2901 is an example of a music playback interface displayed by head unit 1. On interface 2901, the horizontal extension ability is set for layout container 2900. Layout container 2900 stores a plurality of button views, for example, button view 2910, button view 2911, and button view 2913. The width of each of these button views is set to "match parent", and the height is set to a fixed value. In this case, when the horizontal dimension of layout container 2900 changes, these button views are extended horizontally.
[0439] For example, as shown in FIG. 29(2), interface 2902 is an example of a music playback interface displayed by head unit 2. Compared with the width of the screen size of head unit 1, the width of the screen size of head unit 2 is increased, and the width of layout container 2900 is also increased. Therefore, when displaying the music playback interface, head unit 2 extends the button views (such as button view 2910, button view 2911, and button view 2913) in layout container 2900 horizontally. In some examples, as the width of the button view increases, the resources (such as text) displayed on the button view may also increase adaptively. The height of each of these button views remains at the fixed specified value.
[0440] The above embodiment is a solution in which a developer designs an adaptive display interface layout by setting attribute values related to the stretch capability of a View or ViewGroup in a layout file (e.g., an XML file). Alternatively, attribute values related to the stretch capability of a View or ViewGroup may be set in a Java source code file by adding a calling interface.
[0441] Table 10 shows an example of an interface that corresponds to attribute values related to the decompression capabilities of a View or ViewGroup.
[0442] [Table 10]
[0443] The meaning of the decompression capability is described in detail above. The developer may configure a layout file based on the layout design of each display interface in the application by referring to the decompression capability, another adaptive layout capability, and a basic layout capability (e.g., Android native attributes), pack the layout file, other source code and resources, etc. of the application into an installation package (e.g., an APK file), and release the installation package to the application market. The electronic device downloads the installation package from the application market and installs the application. The following describes in detail a solution for implementing an adaptive layout based on the aforementioned layout file when the electronic device runs the application.
[0444] Specifically, the mobile phone executes the measurement procedure shown in Figure 30A(1) and Figure 30A(2) for each layout container in the layout file. This method specifically includes the following steps.
[0445] S3001: Get the width measurement mode and the initial width of a layout container.
[0446] In general, the measurement mode and initial width of a layout container are determined by the MeasureSpec parameters forwarded from the parent layout container. In this specification, MeasureSpec denotes a 32-bit integer. The most significant 2 bits indicate the measurement mode (SpecMode) and the least significant 30 bits indicate the specification size (SpecSize) for the particular measurement mode, i.e. the initial width.
[0447] S3002: Get the maximum / minimum width value of the layout container based on the layout file.
[0448] S3003: Determine whether the layout container's horizontal stretch capability is enabled; if so, execute step S3004; if not, execute step S3011.
[0449] S3004: The maximum / minimum width value is updated to the maximum / minimum width value obtained after maximum / minimum value filtering.
[0450] For example, the mobile phone determines whether the maximum width of the layout container set by the developer in the layout file is greater than or equal to the minimum width of the layout container. If so, the mobile phone determines to use the specified maximum and minimum width of the layout container. In other words, the specified maximum and minimum width of the layout container are the maximum and minimum width values obtained after maximum / minimum filtering.
[0451] S3005: Determine whether the initial width of the layout container is greater than the maximum width; if so, execute step S3006; if not, execute step S3007.
[0452] S3006: Fix the width of the layout container to its maximum width.
[0453] S3007: Determine whether the initial width of the layout container is less than the minimum width; if so, execute step S3008; if not, execute step S3009.
[0454] S3008: Fix the width of the layout container to its minimum width.
[0455] S3009: Perform measurement by using the original width measurement mode and the adjusted width of the layout container.
[0456] In other words, in this case, the measurement mode determined in step S3001 and the width of the layout container adjusted in step S3006 or step S3008 are still used for the measurement.
[0457] S3010: Set the width of child views in a layout container to match_parent.
[0458] In other words, the width of a child view within a layout container changes depending on the width of the layout container.
[0459] S3011: Height measurement mode and initial layout container height Get the.
[0460] Similarly, the measurement mode and initial height of a layout container are determined by the MeasureSpec parameters forwarded from the parent layout container. In this document, MeasureSpec denotes a 32-bit integer. The most significant 2 bits indicate the measurement mode (SpecMode) and the least significant 30 bits indicate the specified size (SpecSize) for the particular measurement mode, i.e. the initial height.
[0461] S3012:Get max / min height value of layout container based on layout file.
[0462] S3013: Determine whether the layout container's vertical stretch capability is enabled; if so, execute step S3014; if not, end the procedure.
[0463] S3014: The maximum / minimum height value is updated to the maximum / minimum height value obtained after maximum / minimum filtering.
[0464] For example, the mobile phone determines whether the maximum height of the layout container set by the developer in the layout file is greater than or equal to the minimum height of the layout container. If so, the mobile phone determines to use the specified maximum height and minimum height of the layout container. In other words, the specified maximum height and minimum height of the layout container are the maximum height and minimum height values obtained after maximum / minimum value filtering.
[0465] S3015: Determine whether the initial height of the layout container is greater than the maximum height; if so, execute step S3016; if not, execute step S3017.
[0466] S3016: Fix the height of the layout container to its maximum height.
[0467] S3017: Determine whether the initial height of the layout container is less than the minimum height; if so, execute step S3018; if not, execute step S3019.
[0468] S3018: Fix the height of the layout container to its minimum height.
[0469] S3019: Perform the measurement by using the original height measurement mode and the adjusted height of the layout container.
[0470] In other words, in this case, the measurement mode determined in step S3011 and the layout container adjusted in step S3016 or step S3018 are height and are still used for the measurement.
[0471] S3020: Set the height of child views in a layout container to match_parent.
[0472] In other words, the height of a child view within a layout container changes depending on the height of the layout container.
[0473] It should be noted that the above measurement procedure is merely an example. The order of performing some steps may be changed, or some steps may be combined or simplified. For example, the height of the layout container may alternatively be measured before the width of the layout container is measured, i.e. steps S3011 to S3020 may be replaced by steps S3001 to S3020. S30 10 is executed before or when the determining whether the initial dimension of the layout container is greater than the maximum dimension and the determining whether the initial dimension of the layout container is less than the minimum dimension may be executed simultaneously, or the determination order may be swapped. The steps of the extended measurement procedure are not limited in this embodiment of the present application.
[0474] It can be seen that when electronic devices having different screen dimensions (e.g., a mobile phone and a tablet computer) use the same layout file (including a layout container with stretching capabilities), the final rendered application interface may present different layout effects according to the measurement procedures of Figures 30A(1) and 30A(2).
[0475] For example, a mobile phone has a screen width of 720 pixels, and a tablet computer has a screen width of 1280 pixels. Both the mobile phone and the tablet computer use the same installation package to install a music application. A layout file corresponding to a play page of the music application includes a layout container configured to display lyrics, where the layout container enables horizontal stretch capability. In addition, the layout container includes one horizontally positioned text view configured to display lyrics. The left and right inner margins of the layout container are 20 pixels each, the maximum width is 1000 pixels, and the minimum width is 500 pixels.
[0476] In this case, when the mobile phone draws the playback page of the music application and executes the measurement procedure of FIG. 30A(1) and FIG. 30A(2), the width of the layout container is calculated as follows: screen width-left and right inner margins=720-20-20=680 pixels. This meets the requirements of the maximum width and minimum width of the layout container. Furthermore, the width of the text view in the layout container is match-parent, so the width of the text view in the layout container is 680 pixels. The mobile phone displays the interface 301 shown in FIG. 30B(1), and the width of the text view in the layout container 302 is 680 pixels. If the layout container is further provided with vertical stretching capability, the height of the layout container and the height of the text view in the layout container may be calculated similarly to the method of calculating the width of the layout container. Details will not be described again in this specification.
[0477] When the tablet computer draws the playback page of the music application and executes the measurement procedures of FIG. 30A(1) and FIG. 30A(2), the width of the layout container is calculated as follows: screen width-left and right inner margins=1280-20-20=1240 pixels. Since the calculated width of the layout container (1240 pixels) is greater than the specified maximum width (1000 pixels), the width of the layout container is adjusted to the specified maximum width of 1000 pixels. Furthermore, since the width of the text view in the layout container is match-parent, the width of the text view in the layout container is 1000 pixels. The tablet computer displays the interface 303 shown in FIG. 30B(2), and the width of the text view in the layout container 304 is 1000 pixels. If the layout container is further provided with vertical stretching capability, the height of the layout container and the height of the text view in the layout container may be calculated similarly to the method of calculating the width of the layout container. Details will not be described again in this specification.
[0478] In conclusion, in the application development phase, the developer of the application sets attributes of adaptive layout capabilities (e.g., expansion capability, proportion capability, equalization capability, hiding capability, or stretch capability) for Views and ViewGroups on a display interface in a layout file. After installing the application, an electronic device having different screen parameters may automatically adjust the dimensions and / or layout of the Views and ViewGroups in each layout container based on the adaptive layout capability attributes of the Views and ViewGroups in the layout file with reference to the screen parameters of the electronic device, so as to implement an adaptive display interface layout. In this way, the developer needs to design only one layout file, so that the display requirements of electronic devices having different screen parameters can be met, and the development and maintenance costs of the developer can be reduced.
[0479] In addition, compared with the solution in which the application installation package needs to carry multiple layout files, the solution in which the application installation package carries one layout file increases the traffic cost and time cost of downloading the application installation package by the electronic device. In addition, after installing the application, the electronic device does not need to store another redundant layout file, which improves the storage space utilization rate of the electronic device.
[0480] It can be understood that the extended multiple adaptive layout capabilities in this embodiment of the present application can be used in combination with each other. For example, different adaptive layout capability attributes are set for different objects (View or ViewGroup) on the same application interface, or two or more adaptive layout capability attributes are set for the same object. It should be noted that when two or more adaptive layout capability attributes are set for the same object, the adaptive layout capability of the layout container may be enabled or disabled for each adaptive layout capability, or the multiple adaptive layout capabilities of the layout container may be enabled or disabled uniformly for the multiple adaptive layout capabilities. This application does not impose restrictions on a specific implementation form. It can be understood that in the actual application development process, in addition to the case where a contradiction occurs during the combination, the aforementioned adaptive layout capabilities can be randomly combined according to the actual requirements. For example, the stretch capability may be combined with any one of the hiding capability, the proportion capability, the equalization capability, and the wrapping capability, and the scaling capability may be combined with any one of the hiding capability, the proportion capability, the equalization capability, and the wrapping capability. Some examples of combinations of several adaptive layout capabilities may be provided herein.
[0481] 1. Extension ability + equalization ability For example, stretch capability and equalization capability are set for the same object. As shown in (1) of FIG. 31, an interface 3101 is a music playback interface. On the interface 3101, a horizontal stretch capability is set for a layout container 3100. The layout container 3100 stores multiple child layout containers, for example, a child layout container 3110, a child layout container 3111, and a child layout container 3113. The width of each of these child layout containers is set to "match parent" and the height is set to a fixed value. In addition, the layout container 3100 is further provided with a vertical equalization capability.
[0482] For example, as shown in FIG. 31(2), interface 3103 is an example of a music playback interface displayed by head unit 2. Compared with the width of the screen dimension of head unit 1 shown in FIG. 31(1), the width of the screen dimension of head unit 2 is increased, and the width of layout container 3100 is also increased. Thus, when displaying the music playback interface, head unit 2 horizontally stretches child layout containers (e.g., child layout container 3110, child layout container 3111, and child layout container 3113) in layout container 3100. In addition, compared with the height of the screen dimension of head unit 1, the height of the screen dimension of head unit 2 is increased, and the width of layout container 3100 is increased. height The height of each of the child layout containers within the layout container 3100 is also increased. However, the height of each of the child layout containers within the layout container 3100 remains a fixed value. Because the layout container 3100 is provided with vertical equalization capabilities, the spacing between these child layout containers within the layout container 3100 increases, maintaining equal spacing between the child layout containers.
[0483] 2. Extendibility + Concealment For example, the stretch capability and the hiding capability are set for the same object. As an example, the music playing interface shown in FIG. 31(1) is still used. On the interface 3101, the horizontal stretch capability is set for the layout container 3100. The layout container 3100 stores multiple child layout containers, for example, a child layout container 3110, a child layout container 3111, and a child layout container 3113. The width of each of these child layout containers is set to "match parent" and the height is set to a fixed value. In addition, the layout container 3100 is further provided with a vertical hiding capability.
[0484] For example, as shown in (3) of FIG. 31, an interface 3104 is an example of a music playback interface displayed by the head unit 3. Compared with the width of the screen dimension of the head unit 1 shown in (1) of FIG. 31, the width of the screen dimension of the head unit 3 is increased, and the width of the layout container 3100 is also increased. Thus, when displaying the music playback interface, the head unit 3 horizontally stretches the child layout containers (e.g., child layout container 3110, child layout container 3111, and child layout container 3113) in the layout container 3100. In addition, compared with the height of the screen dimension of the head unit 1, the height of the screen dimension of the head unit 3 is increased, and the width of the layout container 3100 is also increased. However, the height of each of the child layout containers in the layout container 3100 remains a fixed value. Because the layout container 3100 is provided with vertical hiding capability, as the height of the layout container 3100 increases, more child layout containers, for example, the child layout container 3113, may be displayed. On the interface 3101, if the screen of the head unit 1 is relatively small, the child layout container 3113 may be considered to be hidden.
[0485] In conclusion, electronic devices with different screen parameters can render different display interfaces based on the same layout file. In other words, electronic devices with different screen parameters can adaptively perform display interface layout adjustment based on the layout file to meet different display requirements.
[0486] 3. Stretching ability + Scaling ability + Concealing ability For example, different adaptation capabilities such as stretch capability, scaling capability, and hiding capability are set separately for different objects on the same interface. Fig. 32(1) shows a playback interface 3201 displayed when a mobile phone runs a music application. The playback interface 3201 includes an image view 3202 (configured to display an album cover), a text view 3203 (configured to display song information), and a group of button views 3204 (including button views such as "previous", "play", "next", and "playlist"). The image view 3202 is provided with a scaling capability (horizontal available space percentage and vertical available space percentage), the text view 3203 is provided with a stretch capability, and the group of button views 3204 is provided with a hiding capability.
[0487] FIG. 32(2) shows a playback interface 3205 displayed when the tablet runs a music application. It can be seen that the tablet screen is wider but lower than the mobile phone screen. Therefore, the image view 3202 needs to be scaled down based on the scaling capability corresponding to the image view 3202. Since the text view 3203 has a stretching capability, when the width of the tablet screen is increased, the width of the text view 3203 is also increased. When the width of the tablet screen is increased, the display width of the button view group 3204 may be increased and more button views may be displayed, i.e., some hidden button views (e.g., "Favorites") are displayed. In other words, the scaling capability may perform scaling of the image view when the width / height of the screen changes. In addition, the stretching capability performs adaptive stretching or shrinking of the text view when the width / height of the screen changes, and the hiding capability performs adaptive increase or decrease of the number of button views displayed when the width / height of the screen changes.
[0488] 4. Equalization ability + wrapping ability As an illustrative example, the browsing interface of a gallery application is used.
[0489] FIG. 33(1) shows a browsing interface displayed when the tablet runs a gallery application. The browsing interface includes a layout container, which includes multiple image views (configured to display thumbnails of photos or videos). The layout container is provided with wrapping and equalization capabilities (e.g., a second type of equalization capability). In this case, the widths of the multiple image views are simply wrapping reference values.
[0490] FIG. 33(2) shows a browsing interface displayed when the mobile phone executes a gallery application. First, the mobile phone determines the number of rows of the layout container and the number of image views to be displayed in each row based on the wrapping criterion value of each image view in the layout container. For example, the mobile phone determines that a maximum of three image views are displayed in each row on the mobile phone. In this case, it may be determined that five image views need to be displayed in two rows on the mobile phone. In addition, because the layout container is further provided with an equalization capability, when displaying image views in each row, the mobile phone further ensures that the image views in each row have the same spacing. On the mobile phone, the number of image views to be displayed in the second row is equal to the number of image views to be displayed in the first row. image Note that the number of image views displayed in each row is less than the number of views, and the spacing between the image views in the second row is greater than the spacing between the image views in the first row. By comparing the browsing interface in Fig. 33(2) with the browsing interface in Fig. 33(1), it can be seen that although the width of a mobile phone is smaller than the width of a tablet, the number of image views displayed in each row is reduced and the spacing between the image views in each row is adaptively adjusted.
[0491] Alternatively, FIG. 33(3) shows another browsing interface displayed when the tablet executes a gallery application. The difference from the browsing interface shown in FIG. 33(2) is in the way of displaying image views in the second row. On the browsing interface shown in FIG. 33(2), the tablet recalculates the interval between adjacent child views based on the number of child views actually included in the second row, the width of each child view, and the specified equalization type, and performs display based on the recalculated interval. On the browsing interface shown in FIG. 33(3), the tablet directly displays child views in the second row based on the calculated interval in the first row. In other words, the interval between adjacent child views in the second row is equal to or close to the interval between adjacent child views in the first row.
[0492] A developer may find that they do not need to pay attention to the screen dimensions of the electronic device, and do not need to pay attention to the number of image views that may be displayed in a row, but may directly use the wrapping and equalization capabilities to enable the electronic device to adaptively perform layout adjustments and adaptively adjust the spacing between the image views, thereby achieving a grid effect.
[0493] 5. Equalization ability + concealment ability As an illustrative example, the playback interface of a music application is used.
[0494] In this specification, FIG. 34 (1) shows a playback interface displayed when the tablet executes a music application. The playback interface includes one layout container, which includes multiple image button views ("favorites", "previous", "play", "next", and "playlist"). The layout container is provided with an equalization capability (e.g., a second type of equalization capability) and a hiding capability. The hiding priority of each of "previous", "play", and "next" is lower than the hiding priority of "playlist", which is lower than the hiding priority of "favorites".
[0495] In this specification, (2) of FIG. 34 shows a playback interface displayed when the mobile phone executes a music application. Compared with the tablet, the width of the mobile phone is reduced, and the width of the layout container is reduced accordingly. In this case, the mobile phone first determines that the layout container cannot display all the icon button views based on the width of the layout container and the width of each icon button view. The mobile phone determines which icon button views need to be hidden based on the hiding priority of the icon button views. First, the mobile phone hides the icon button view of "favorites" and determines whether the remaining four icon button views may be displayed in the layout container. Then, the mobile phone determines the spacing between the four icon button views based on the dimensions of the remaining four icon button views and the dimensions of the layout container. If the layout container cannot display the four icon button views, the icon button views that need to be hidden are further determined, and so on.
[0496] An example of a layout file with both equalization and concealment capabilities enabled is provided herein. <hwLayout xmlns:android="http: / / schemas.android.com / apk / res / android" xmlns:app="http: / / schemas.android.com / apk / res-auto" / *Other configurations omitted* / android:orientation="horizontal" / / Sets the layout orientation of the layout container app:equalizationcapabilityenabled="true" / / Enables equalization capabilities for the layout container app:equalization type="second type" / / Set the second type equalization ability app:enable hiding ability="true" / / Enables the hiding ability of the layout container <imagebutton レイアウトコンテナのアイコンボタンビューを設定する *他の構成を省略* android:src=""@drawable / trends_ic_favorite”" app:隠蔽優先度=""3” / "> / / Set the hiding priority of the first icon button view of the layout container <ImageButton / *Other configurations omitted* / android:src="@drawable / trends_ic_previous” app:hidingpriority="1" / > / / Sets the hiding priority of the second icon button view of the layout container <ImageButton / *Other configurations omitted* / android:src="@drawable / trends_ic_pause” app:hidingpriority="1" / > / / Set the hiding priority of the third icon button view of the layout container <ImageButton / *Other configurations omitted* / android:src="@drawable / trends_ic_next” app:hidingpriority="1" / > sets the hiding priority of the fourth icon button view of the layout container <ImageButton / *Other configurations omitted* / android:src="@drawable / trends_ic_list” app:hidingpriority="2" / > sets the hiding priority of the fifth icon button view of the layout container
[0497] 6. Equalization + Scaling Capabilities As an illustrative example, the browsing interface of the gallery application is still used.
[0498] FIG. 35(1) shows a browsing interface displayed when a mobile phone executes a gallery application. The gallery application includes a layout container, which includes multiple image views (configured to display thumbnails of photos or videos). The layout container is provided with a scaling capability, and a horizontal available space percentage and a vertical available space percentage are set for each image view. The layout container is further provided with an equalization capability (e.g., a second type of equalization capability).
[0499] FIG. 35(2) shows a browsing interface displayed when a tablet runs a gallery application. Compared to a mobile phone, a tablet has a wider width. The image view is enlarged based on the width of the layout container and the horizontal and vertical available space percentages of the image view. After the width of the enlarged image view is determined, the spacing between two adjacent image views is determined based on the available space of the layout container.
[0500] 7. Concealment + wrapping ability As an illustrative example, the browsing interface of a gallery application is used.
[0501] FIG. 36(1) shows a browsing interface displayed when the tablet runs a gallery application. The browsing interface includes one layout container, which includes multiple image views (configured to display thumbnails of photos or videos), namely image view A to image view E. The layout container is provided with wrapping and hiding capabilities. Image views A and E have the highest hiding priority, image views B and D have the second highest hiding priority, and image view C has the lowest hiding priority. In this case, the widths of the multiple image views are simply wrapping reference values.
[0502] FIG. 36(2) is a schematic diagram of an interface in which a tablet displays two windows on a split screen. The left window is configured to display a browsing interface of a gallery application. The right window is configured to display a playback interface of a music application. Since the dimensions of the window configured to display the browsing interface of the gallery application are reduced, the tablet is triggered to display the layout container in a wrapping manner. Based on the wrapping criterion value of each image view in the layout container, it is determined that only one image view can be displayed in each row. In this case, the five image views are displayed in a precisely vertical direction on the interface shown in FIG. 36(2). If the height of the window used by the tablet to display the browsing interface of the gallery application is insufficient to display the five image views, the tablet is triggered to hide the five image views based on the hiding priority. On the interface shown in FIG. 36(3), image view A and image view E, which have the highest hiding priority, are not displayed.
[0503] Below is an example of one layout file (XML file): A layout container with hiding capability enabled is set in the layout file and the layout container contains four child views, namely, four image views. <hwLayout xmlns:android="http: / / schemas.android.com / apk / res / android" xmlns:app="h...
Claims
1. 1. An application interface layout method, wherein an electronic device installs an application installation package for a first application, the application installation package including a first layout file, the first layout file indicating N child views and enabled preset capabilities, where N is a positive integer, the preset capabilities including one or more of an expand capability, a proportion capability, an equalize capability, a stretch capability, and a hide capability, the method comprising: receiving, by the electronic device, a first operation performed by a user on a first interface; determining, by the electronic device in response to the received first operation, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities, the device parameters of the electronic device including at least one of a screen type value, a screen dimension value, or a running state value of the electronic device, and the attribute values of the N child views are used to indicate sizes and positions of the N child views on a second interface; displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; Including, the preset capability is the expanded capability, the first layout file indicates that the N child views are to be arranged in a first orientation in a first layout container, the first orientation being a horizontal orientation or a vertical orientation; determining, by the electronic device, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities; determining, by the electronic device, dimensions of the first layout container in the first orientation based on the device parameters; determining N1 child views and an (N1+1)th child view of the N child views based on the dimensions of the first layout container in the first orientation and dimensions of the N child views in the first orientation, where N1 is less than N; Including, displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; fully displaying the N1 child views by the electronic device; and partially displaying the (N1+1)th child view on the second interface based on the attribute values of the N child views. Including, Application interface layout method.
2. 1. An application interface layout method, wherein an electronic device installs an application installation package for a first application, the application installation package including a first layout file, the first layout file indicating N child views and enabled preset capabilities, where N is a positive integer, the preset capabilities including one or more of an expand capability, a proportion capability, an equalize capability, a stretch capability, and a hide capability, the method comprising: receiving, by the electronic device, a first operation performed by a user on a first interface; determining, by the electronic device in response to the received first operation, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities, the device parameters of the electronic device including at least one of a screen type value, a screen dimension value, or a running state value of the electronic device, and the attribute values of the N child views are used to indicate sizes and positions of the N child views on a second interface; displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; Including, the preset capability is the hiding capability, and the first layout file indicates that the N child views are to be arranged in a first orientation of a first layout container, indicates dimensions of each of the N child views in the first orientation, and indicates an inner margin of the first layout container in the first orientation; determining, by the electronic device, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities; determining, by the electronic device, dimensions of the first layout container in the first orientation based on the device parameters; determining M child views from the N child views when a first dimension is greater than a second dimension, where M is an integer less than N, and the first dimension is determined based on the dimensions of the N child views in the first orientation, and the second dimension is determined based on the dimensions of the first layout container in the first orientation and the inner margin of the first layout container in the first orientation; Including, displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; The application interface layout method includes displaying, by the electronic device, the M child views on the second interface based on the attribute values of the N child views.
3. 1. An application interface layout method, wherein an electronic device installs an application installation package for a first application, the application installation package including a first layout file, the first layout file indicating N child views and enabled preset capabilities, where N is a positive integer, the preset capabilities including one or more of an expand capability, a proportion capability, an equalize capability, a stretch capability, and a hide capability, the method comprising: receiving, by the electronic device, a first operation performed by a user on a first interface; determining, by the electronic device in response to the received first operation, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities, the device parameters of the electronic device including at least one of a screen type value, a screen dimension value, or a running state value of the electronic device, and the attribute values of the N child views are used to indicate sizes and positions of the N child views on a second interface; displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; Including, the preset capability is the stretch capability, the first layout file indicates that the N child views are arranged in a second orientation of a first layout container, and indicates a first threshold and / or a second threshold of the first layout container in a first orientation, the second orientation being different from the first orientation, and the second threshold being smaller than the first threshold; determining, by the electronic device, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities; determining, by the electronic device, initial values of dimensions of the first layout container in the first orientation based on the device parameters; determining that the dimension of the first layout container in the first orientation is the first threshold if the initial value is greater than the first threshold, or determining that the dimension of the first layout container in the first orientation is the second threshold if the initial value is less than the second threshold; determining dimensions of a first child view within the first layout container in the first orientation based on the dimensions of the first layout container in the first orientation, the first child view being one of the N child views; Including, displaying, by the electronic device, the N child views on the second interface based on the attribute values of the N child views; The application interface layout method includes displaying, by the electronic device, the first child view on the second interface based on the attribute values of the N child views.
4. the first layout file includes preset parameters corresponding to the preset capabilities; determining, by the electronic device, attribute values of the N child views based on device parameters of the electronic device and the preset capabilities; determining, by the electronic device, the attribute values of the N child views based on the device parameters of the electronic device, the preset capabilities, and the preset parameters. The method according to any one of claims 1 to 3, comprising:
5. The method of claim 1 , wherein the running states of the electronic device include one or more of a landscape / portrait state, a split screen state, and a folded state of the electronic device.
6. 6. The method of claim 1, wherein the first operation is one of: launching the first application, jumping to the second interface, or switching an execution state of the electronic device.
7. The method further comprising: receiving a second operation performed by the user on the second interface; displaying a third interface in response to the second operation, the third interface displaying an (N1+2)th child view of the N child views; The method of claim 1, further comprising:
8. the first layout file further indicates obscuring priorities of the N child views, and determining M child views from the N child views when a first dimension is greater than a second dimension; determining the M child views from the N child views based on the obscurance priorities of the N child views if the first dimension is greater than the second dimension; 3. The method of claim 2, comprising:
9. determining dimensions of a first child view within the first layout container in the first orientation based on the dimensions of the first layout container in the first orientation; determining that the dimensions of the first child view in the first orientation are the same as the dimensions of the first layout container in the first orientation; or determining that the dimensions of the first child view in the first orientation are the dimensions of the first layout container in the first orientation minus an inner margin of the first layout container in the first orientation; 4. The method of claim 3, comprising:
10. The method of claim 1 , wherein each of the N child views is one of a text view, an edit view, a button view, and an image button view.
11. 11. An electronic device comprising a processor, a memory and a touch screen, wherein the memory, the touch screen and the processor are coupled, the memory configured to store computer program code, the computer program code comprising computer instructions, and wherein execution of the computer instructions in the memory by the processor enables the electronic device to perform a method according to any one of claims 1 to 10.
12. 11. A computer readable storage medium comprising computer instructions which, when executed on an electronic device, enable the electronic device to perform the method of any one of claims 1 to 10.
13. A computer program comprising computer instructions which, when executed on a computer, enable the computer to carry out the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Floating window management method and related device
CN110489043A
Display device, display method and display program
JP2013145515A
User interface display method and terminal device
WO2019242440A1
