Screen adaptation method and device for display object, electronic device and storage medium
By determining the adaptation relationship between the size of the display object and the screen, calculate the display of the adaptation, and adapt to the screen, solve the problem of displaying object adaptation on different specifications, and achieve efficient and universal content. Show the adaptation effect.
Patent Information
- Application Number
- CN202110751438.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-02
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2041-07-02
AI Technical Summary
The prior art is difficult to realize the adaptive display of display objects on screens of different specifications, resulting in high development costs, low development efficiency, and inability to adapt to new models of screens.
By determining the target size unit of the display object and the screen size unit of the screen, the unit adaptation relationship is established, and the display adaptation of the adaptation relationship is calculated based on the relationship, and the display object is then adapted on the screen.
The adaptation and display of the object of the object through a single set of layout files is achieved on the screen of different specifications, reducing development costs, improving development efficiency, and can adapt to screens of any size in the future.
Smart Images

Figure CN113467738B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of device display technology, and in particular to a screen adaptation method and device for a display object, an electronic device, and a storage medium. Background Art
[0002] With the continuous innovation of display screens of electronic devices, the models and specifications of display screens are becoming more and more diversified. The sizes and resolutions of display screens of different models and specifications are not the same, which brings new problems to object display in application development.
[0003] Taking the user interface (UI) page display of some applications as an example, during the operation of the application, the page background image needs to be able to adapt to the size of the display screen. At the same time, the UI elements in the page need to coincide with the specified positions on the page background image, so as to achieve the desired UI page display effect during the design process on the display screen.
[0004] However, due to the different sizes of different display screens, the same UI page of the same application may present quite different effects when displayed on screens of different sizes. In this regard, although during the development phase of the UI page, multiple sets of layout files can be written for the existing multiple models of display screens to specifically adapt to various display screens, this greatly increases the development cost and is not conducive to improving development efficiency. In addition, such multiple sets of layout files cannot be adapted to new models of screens that may appear in the future. Summary of the invention
[0005] In view of the problem that existing display objects are not compatible with display on screens of different specifications, the purpose of the present application is to provide a screen adaptation method and device, an electronic device and a storage medium for display objects, which can determine a unit adaptation relationship and a display adaptation amount that satisfies the unit adaptation relationship based on the target size unit of the display object and the screen size unit of the screen, thereby allowing the display object to be adaptively displayed on screens of different specifications.
[0006] In a first aspect, an embodiment of the present application provides a screen adaptation method for a display object, the screen adaptation method comprising: determining a target size unit of a display object to be displayed and a screen size unit of a screen; based on the target size unit and the screen size unit, determining a unit adaptation relationship between the target size unit and the screen size unit; according to the unit adaptation relationship, determining a display adaptation amount that satisfies the unit adaptation relationship; based on the display adaptation amount, adapting the display object to be displayed on the screen.
[0007] Further, the target size unit of the display object is determined by: acquiring a layout file of the display object; and extracting the target size unit from the layout file.
[0008] Furthermore, the layout file is generated in the following manner: obtaining object size parameters and original size units of a display object; replacing the original size units with the target size units to obtain a layout size of the display object consisting of the object size parameters and the target size units; and generating a layout file of the display object based on the layout size.
[0009] Further, the object size parameters include first dimension size parameters and second dimension size parameters; the layout size includes first dimension layout size and second dimension layout size, and the target size unit is used to replace the original size unit to obtain the layout size of the display object composed of the object size parameters and the target size unit, including: replacing the original size unit of the first dimension size parameter with the target size unit to obtain the first dimension layout size composed of the first dimension size parameter and the target size unit; based on the target size unit and the original size unit, performing scrolling layout wrapping on the second dimension size parameter of the display object to obtain the second dimension layout size of the display object.
[0010] Furthermore, based on the target size unit and the screen size unit, a unit adaptation relationship between the target size unit and the screen size unit is determined, including: based on the target size unit and the screen size unit, determining an adaptation standard unit conversion condition associated with the target size unit and the screen size unit in the standard unit conversion condition of the operating environment; based on the adaptation standard unit conversion condition, determining the unit adaptation relationship.
[0011] Furthermore, based on the unit adaptation relationship, a display adaptation amount that satisfies the unit adaptation relationship is determined, including: obtaining object size parameters of the display object and screen size parameters of the screen; applying the object size parameters and the screen size parameters to the unit adaptation relationship, and solving the display adaptation amount that satisfies the unit adaptation relationship.
[0012] Furthermore, based on the display adaptation amount, the display object is adapted to be displayed on the screen, including: replacing the adaptation display coefficient corresponding to the display adaptation amount in the operating environment with the display adaptation amount; and adapting the display object to be displayed on the screen based on the replaced adaptation display coefficient and the layout file of the display object.
[0013] Furthermore, the adaptive display coefficient includes an application-level display coefficient or a page-level display coefficient, the application-level display coefficient is used for displaying all pages in the application, and the page-level display coefficient is used for displaying the current page.
[0014] Furthermore, determining the target size unit of the display object to be displayed and the screen size unit of the screen includes: monitoring the action of the display object, and identifying whether the display object has an adaptation interface when monitoring the display object to perform a new action; and determining the target size unit of the display object to be displayed and the screen size unit of the screen when identifying that the display object has an adaptation interface.
[0015] Furthermore, the adaptation interface predefines an adaptation benchmark of the display object and an object size parameter of the display object corresponding to the adaptation benchmark; the adaptation benchmark includes taking the first dimension size of the display object as a benchmark or taking the second dimension size of the display object as a benchmark, and the first dimension size and the second dimension size are the sizes of the display object in different directions.
[0016] Furthermore, the display object includes one or more of user interface elements used to generate a user interface page, intervals between user interface elements, a user interface page border, a user interface page background image, and a position of the user interface page background image; the target size unit includes any one of pounds, pixels, device-independent pixels, scalable pixels, inches, and millimeters; the screen size unit includes any one of pounds, pixels, device-independent pixels, scalable pixels, inches, and millimeters.
[0017] In the second aspect, an embodiment of the present application also provides a screen adaptation device for a display object, the screen adaptation device comprising: a unit determination unit, which determines a target size unit of the display object and a screen size unit of the screen; an adaptation relationship determination unit, which determines a unit adaptation relationship between the target size unit and the screen size unit based on the target size unit and the screen size unit; an adaptation amount determination unit, which determines a display adaptation amount that satisfies the unit adaptation relationship according to the unit adaptation relationship; and an adaptation display unit, which adapts the display object on the screen based on the display adaptation amount.
[0018] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the steps of the screen adaptation method as described in any one of the first aspects are implemented.
[0019] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the screen adaptation method as described in any one of the first aspects are executed.
[0020] The screen adaptation method and device, electronic device and storage medium of the display object provided in the embodiments of the present application can be based on the unit adaptation relationship between the display object to be displayed and the size unit of the screen, and determine the display adaptation amount that satisfies the unit adaptation relationship, so as to adapt the display object to be displayed on the screen based on the display adaptation amount. Compared with the method in the prior art that cannot achieve adaptation using a single set of layout files or requires pre-writing multiple sets of layout files for screens of different specifications, the screen adaptation method and device, electronic device and storage medium of the display object according to the embodiments of the present application can achieve adaptive display of display objects on screens of different specifications through a single set of layout files, and can accurately position different display objects, reduce the workload of adaptation, and improve work efficiency.
[0021] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, the target size unit can be extracted from the layout file of the display object, so that the target size unit can be determined according to the preset layout file of the display object to be displayed, thereby realizing dynamic determination of the target size unit for different display objects.
[0022] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, a layout file can be generated based on the object size parameters and target size units of the display object, so that the layout file can adapt to the screen adaptation process.
[0023] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, the scrolling layout wrapping can be selectively performed on the second dimension size parameter based on the first dimension size parameter as a reference to generate a layout file, thereby allowing adaptive display of the display object in different dimensions.
[0024] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, the unit adaptation relationship can be determined based on the standard unit conversion conditions of the operating environment, so that the unit adaptation relationship can be determined according to the unit conversion rules in the operating environment, so as to achieve adaptation according to different unit conversion rules in the operating environment.
[0025] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, the display adaptation amount can be used to replace the adaptive display coefficient in the operating environment to achieve adaptive display on the screen. In addition, by setting the application-level display coefficient or the page-level display coefficient, the display of all pages in the application can be adapted, or the display of the current page in the application can be adapted.
[0026] Furthermore, according to the screen adaptation method and device, electronic device and storage medium of the display object of the present application, it is possible to determine whether to execute the adaptation process by monitoring the actions of the display object and identifying the adaptation interface, thereby allowing selective adaptation display of different display objects.
[0027] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 A schematic diagram showing a flow chart of a screen adaptation method for a display object provided in an embodiment of the present application;
[0030] Figure 2 A schematic diagram showing the structure of a screen adaptation device for displaying an object provided in an embodiment of the present application is shown;
[0031] Figure 3 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0032] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.
[0033] First, the application scenarios to which this application can be applied are introduced. This application can be applied to object display scenarios of operating systems such as the Android system, but it should be understood that the application scenarios to which this application can be applied are not limited thereto, and can also be applied to object display scenarios in other operating environments. In general, this application is intended to provide a unique concept of screen adaptation display of a display object, but is not intended to limit the specific application scenarios or application methods of the concept. As long as it is related to the relevant scenarios of the concept provided by this application, the concept provided by this application can be applied.
[0034] It is worth noting that with the development of device hardware, the operating environment is becoming more and more differentiated. In some existing screen displays, the display of the system or application cannot be well adapted to the hardware device, resulting in poor display effects.
[0035] Taking the application development of the Android system as an example, in some UI pages, it is necessary to design the UI elements to overlap with the specified positions of the page background image one by one, so as to realize the editable operation of the elements at each specified position of the background image. Such a design is relatively easy to implement on the web side, but on the native Android side, due to the serious fragmentation of Android, the screen resolution and screen size are of various types and models, which makes it difficult to achieve basically consistent display effects on devices of various resolutions and sizes. Therefore, in the layout positioning of the UI page, if absolute layout positioning is used, a set of layout files can only adapt to the device screen of the same size and resolution. If you need to adapt to multiple screen sizes and resolutions, you need to pre-write multiple sets of layout files. In the case where the UI page is not compatible with the screen, not only the problem of UI page layout is involved, but also the problem of overlapping positioning of UI elements and background images needs to be considered.
[0036] In this regard, for the case where the screen size is measured in pixels (px), the Android system provides a way to display pages in device-independent pixels (dp) units to alleviate the display adaptation problem caused by screen differences, that is, converting dp units into px units. Specifically, the dp unit itself has nothing to do with the pixel unit of the screen, so the screen pixel density constructed as a conversion amount between the dp unit and the px unit is used to convert the dp unit of the page size into the px unit of the screen size. The screen pixel density of different screens is different, but for the same screen, the screen pixel density is fixed. In this case, when positioning UI elements, it is still impossible to obtain a good adaptive display by simply using dp units for the spacing and distance between the elements and the background.
[0037] For example, in the Android system, the dp unit of the display object can be converted to the px unit of the screen by the following equations (1) to (3) before the display object is rendered:
[0038] px=density×dp (1)
[0039] density=dpi / 160 (2)
[0040] px=dp×(dpi / 160) (3)
[0041] Where density refers to the pixel density of the screen, and dpi is the converted value of the pixel density of the screen (also called "dots per inch"), which represents the number of pixels per inch of the image, and can be calculated based on the actual resolution and size of the screen. Each model of screen has a corresponding dpi. As can be seen from the above formula, different dpi will lead to different densities, and different densities will lead to different total sizes of the screen in dp units (for example, total width or total height).
[0042] Based on the above formula, we can get the following formula (4):
[0043] The total size of the screen in px units / density = the total size of the screen in dp units (4)
[0044] In this case, it is assumed that there are two models of screens, namely screen 1 and screen 2, where the screen width of screen 1 is 1080px and 480dpi. According to formula (4), the total width of screen 1 in dp units is 1080 / (480 / 160)=360dp; the screen width of screen 2 is 1440px and 560dpi. According to formula (4), the total width of screen 2 in dp units is 1440 / (560 / 160)=411dp.
[0045] It can be seen that when the screen size is different, the display size in dp units converted by the above formula is different. In fact, in a single layout file, the dp value of the display object is fixed, which leads to different display ranges of the display object when displayed on screens of different sizes.
[0046] Continuing with the above example, assuming that the width of the display object is set to 100dp in the layout file, the display width of the display object on the above screen 1 accounts for 27.8% of the screen width of the entire screen 1 (i.e., 100 / 360=0.278); and on the above screen 2, the display width of the display object accounts for 24.3% of the screen width of the entire screen 1 (i.e., 100 / 411=0.243). It can be seen that the actual display ratio of the display object with the same dp value on screens of different sizes will change greatly, and the visual effect of the human eye will vary greatly. For example, on a screen with higher pixels (such as screen 2), the display range will become smaller and smaller.
[0047] In general, in existing screen display solutions, it is impossible to use a single layout file to adapt display objects to display on screens of different sizes.
[0048] Based on this, an embodiment of the present application provides a screen adaptation method for display objects, so as to allow the display objects to be adapted for display on screens of different sizes using a single layout file, thereby being able to adapt the display objects to all device screens without adding layout files, and also being able to adapt to any size of screen that may appear in the future.
[0049] The following will refer to Figure 1 The screen adaptation method for displaying an object according to an embodiment of the present application is described in detail. Here, the execution subject of the screen adaptation method for displaying an object provided by the embodiment of the present application may be a processor of an electronic device such as a smart phone, a tablet computer, a television, a computer, etc.
[0050] like Figure 1 As shown in , the screen adaptation method of the display object provided in the embodiment of the present application includes the following steps:
[0051] S101 : Determine a target size unit of a display object to be displayed and a screen size unit of a screen.
[0052] In this step, the display object may refer to an object to be displayed on the screen to present a specific visual effect. For example, the display object may include all of the UI elements used to generate the UI page, the intervals between UI elements, the UI page border, the UI page background image, and the position of the UI page background image. Here, it should be noted that although the display object is described herein using the UI page as an example, the display object described in the embodiment of the present application is not limited thereto, and it may also refer to any object that needs to be displayed on the screen.
[0053] The target size unit of the display object refers to the reference size unit used to fit the display object to the screen, which will participate in the adaptation calculation. The screen adaptation method is the process of adapting the target size unit to the screen size unit. As an example, the target size unit may include any one of points (pt), pixels (px), device independent pixels (dp), scalable pixels (sp), inches (in), and millimeters (mm). Here, the target size unit is different from the screen size unit.
[0054] As an example, the target size unit may be the original size unit of the display object. For example, the display object may be a UI design drawing, and the target size unit may be the original size unit used by the UI designer when designing the UI drawing. For example, both the original size unit and the target size unit of the display object may be dp.
[0055] As another example, the target size unit may be a size unit that has a unit conversion relationship with the original size unit, rather than the original size unit of the display object itself. For example, the original size unit of the display object may be px, while the target size unit may be pt.
[0056] As an example, the target size unit of the display object may be determined in the following manner: obtaining a layout file of the display object; and extracting the target size unit from the layout file.
[0057] Specifically, during the system or application development phase, it is necessary to write a layout file for the display object so that the corresponding display object can be displayed by calling the layout file during the operation of the system or application. The layout file can contain the size unit of the display object, and the size unit set in the layout file can be used as the target size unit for adaptive display. Here, the generation process of the layout file will be described in detail below.
[0058] The screen size unit refers to the size unit of the screen hardware itself. The screen size unit can be obtained from the system parameters of the operating environment. For example, in the Android system, the screen size unit can be obtained from the DisplayMetrics class. Generally speaking, the size unit of the existing screen is usually px, but the embodiments of the present application are not limited thereto, and the screen size unit may also include any one of pt, dp, sp, in, and mm.
[0059] According to an embodiment of the present application, a layout file of a display object can be generated in the following manner: S1011, obtaining object size parameters and original size units of the display object; S1012, replacing the original size units with target size units to obtain the layout size of the display object consisting of the object size parameters and the target size units; S1013, generating a layout file of the display object based on the layout size.
[0060] In step S1011, the object size parameter of the display object may be a size parameter of the original design drawing of the display object, which is a unitless value. The object size parameter may include a first dimension size parameter and a second dimension size parameter. Here, the first dimension size and the second dimension size may be the size of the display object in different directions, for example, the first dimension size parameter and the second dimension size parameter may be a width size parameter and a height size parameter of the display object, respectively.
[0061] In step S1012 , corresponding to the object size parameter, the layout size may include a first-dimensional layout size and a second-dimensional layout size.
[0062] As an example, in this step, the original size unit of the first dimension size parameter can be replaced by the target size unit to obtain the first dimension layout size composed of the first dimension size parameter and the target size unit, and based on the target size unit and the original size unit, a scrolling layout wrapping can be performed on the second dimension size parameter of the display object to obtain the second dimension layout size of the display object.
[0063] Specifically, the adaptation benchmark of the display object can be defined in the layout file. For example, when the first dimension size parameter and the second dimension size parameter are respectively the width size parameter and the height size parameter, when it is defined that the display object is adapted based on the width, the vertical layout of the display object can be wrapped by, for example, a vertical ScrollView to perform a scrolling layout; when it is defined that the display object is adapted based on the height, the horizontal layout of the display object can be wrapped by, for example, a horizontal HorizontalScrollView to perform a scrolling layout.
[0064] In step S1013, the layout size may be written into the layout file of the display object.
[0065] The above method of generating a layout file of a display object may be performed in the application development stage, and the layout file generated based on the above steps may be used to implement adaptive display of the display object on the screen in the application running stage.
[0066] S102: Determine a unit adaptation relationship between the target size unit and the screen size unit based on the target size unit and the screen size unit.
[0067] In this step, the unit adaptation relationship may represent the conversion correspondence between the target size unit and the screen size unit, for example, it may be an expression of unit conversion.
[0068] In one example, the unit adaptation relationship may be determined based on the operating environment. Specifically, step S102 may include the following operations:
[0069] S1021, based on the target size unit and the screen size unit, determining, in the standard unit conversion conditions of the operating environment, an adaptation standard unit conversion condition associated with the target size unit and the screen size unit;
[0070] S1022: Determine a unit adaptation relationship based on the adaptation standard unit conversion condition.
[0071] Specifically, the standard unit conversion condition is a unit conversion rule specified in the operating environment, and all unit conversion actions in the operating environment are performed according to the rule. Here, the adaptation standard unit conversion condition related to the target size unit and the screen size unit can be found in the standard unit conversion condition, and the unit adaptation relationship can be determined based on the adaptation standard unit conversion condition.
[0072] Taking the Android system as an example, when the target size unit is pt and the screen size unit is px, the system may have an adaptation standard unit conversion condition for converting between the unit px and the unit pt:
[0073] "case COMPLEX_UNIT_PX:return value;
[0074] case COMPLEX_UNIT_PT:return value*metrics.xdpi*(1.0f / 72)",
[0075] Based on the adaptation standard unit conversion condition, the unit adaptation relationship between the unit px and the unit pt can be extracted, which can be shown in the following formula (5):
[0076] px unit size = pt unit size × DisplayMetrics.xdpi / 72 (5)
[0077] In formula (5), DisplayMetrics.xdpi is the adaptation display coefficient in the unit adaptation relationship. In the Android system, it represents the DisplayMetrics class used for display in the Android system, and xdpi is a member variable in the DisplayMetrics class. The DisplayMetrics instance can be obtained through Resources#getDisplayMetrics in the Android system, where Resources is obtained through the Context of Activity or Application. From this formula, it can be seen that if the size value of the px unit is unchanged, if the size value of the px unit is to be equal to the actual value of the screen, it is necessary to dynamically change the current system's adaptation display coefficient DisplayMetrics.xdpi, which will be described in detail below. In this article, the display coefficient (for example, the adaptation display coefficient and the associated display coefficient mentioned below) refers to the conversion coefficient used for conversion between different size units.
[0078] In another example, the unit adaptation relationship may not be determined from the operating environment. For example, the unit adaptation relationship may be pre-stored information, for example, all existing conversion expressions between target size units and screen size units may be pre-stored in the memory for direct call during screen adaptation.
[0079] S103: Determine a display adaptation amount that satisfies the unit adaptation relationship according to the unit adaptation relationship.
[0080] In this step, the display adaptation amount may be used to adapt the display object to the screen, which may be determined according to the unit adaptation relationship.
[0081] As an example, step S103 may include: S1031, obtaining object size parameters of the display object and screen size parameters of the screen; S1032, applying the object size parameters and the screen size parameters to the unit adaptation relationship to solve the display adaptation amount that satisfies the unit adaptation relationship.
[0082] In step S1031, as described above, the object size parameter of the display object may be a size parameter of the original design drawing of the display object, which is a unitless value. The object size parameter may include size parameters of the display object in multiple different dimensions, for example, the object size parameter may include a height size parameter and a width size parameter of the display object.
[0083] In one example, the object size parameters may be obtained from a layout file of the display object. In another example, the object size parameters may be obtained from an adaptation interface preset for the display object, and the adaptation interface may include pre-stored object size parameters of the display object. The specific setting method of the adaptation interface will be described in detail below.
[0084] In step S1031, the screen size parameters can be obtained from the system parameters of the operating environment. For example, in the Android system, a core class for adaptation can be created, and the core class is used to calculate and save the attribute values involved in the adaptation process. The core class can be named AutoFit class, and can be initialized in the AutoFit class to obtain and save the values of widthPixels and heightPixels in the DisplayMetrics class at the current application level as the width size parameters and height size parameters of the screen, respectively.
[0085] In step S1032, the unitless object size parameter and the screen size parameter may be substituted into the unit adaptation relationship determined in step S102 to solve the display adaptation amount.
[0086] In this step, the display adaptation amount can be used to change the adaptation display coefficient in the unit adaptation relationship of the operating environment, so as to dynamically establish a new unit adaptation relationship based on the size of the display object to be displayed and the size of the current screen, and replace the original unit adaptation relationship in the operating environment to achieve a good adaptation effect between the display object and the screen.
[0087] Specifically, in the process of calculating the display adaptation amount through the object size parameter and the screen size parameter, the unit of the object size parameter may be ignored, and only the size value thereof may be input.
[0088] Here, in the screen adaptation method according to the embodiment of the present application, since the display adaptation amount that satisfies the unit adaptation relationship can be dynamically solved based on the unit adaptation relationship for the object size parameters of the display object to be displayed and the screen size parameters of the screen, the display object with an original design drawing of any unit can be adapted to the screen display through the dynamically obtained display adaptation amount. Therefore, display adaptation is allowed while only paying attention to / storing / using the size value of the original design drawing of the display object without considering its size unit, thereby improving the universality and application flexibility of the adaptation scheme.
[0089] S104: Adapt and display the display object on the screen based on the display adaptation amount.
[0090] In this step, the unit adaptation relationship may be determined in step S102 and then displayed accordingly.
[0091] In one example, when there are standard unit conversion conditions in the operating environment, the adaptation display coefficient corresponding to the display adaptation amount in the standard unit conversion conditions of the operating environment can be replaced by a display adaptation amount dynamically calculated based on the object size parameters and the screen size parameters, and the display object can be adaptively displayed on the screen based on the replaced adaptation display coefficient and the layout file of the display object.
[0092] The adaptation display coefficient may be a parameter used for screen display in the operating environment. Taking the Android system as an example, the system may have a DisplayMetrics class for screen display, and the adaptation display coefficient may be a member variable of the DisplayMetrics class. Here, the adaptation display coefficient corresponding to the display adaptation amount refers to the display coefficient involved in the process of determining the unit adaptation relationship, such as the adaptation display coefficient in the unit adaptation relationship determined based on the standard unit conversion condition mentioned in step S102 above, such as the DisplayMetrics.xdpi value in the Android system mentioned above.
[0093] In other words, in this example, the display adaptation amount is the amount corresponding to the adaptation display coefficient in the standard unit conversion condition of the operating environment, and replacing the adaptation display coefficient in the operating environment with the obtained display adaptation amount is a process that can dynamically change the display rules of the operating environment according to the display object.
[0094] As an example, when the display object is a UI page, the adaptation display coefficient may include an application-level display coefficient or a page-level display coefficient, wherein the application-level display coefficient is used for the display of all pages in the application, and the page-level display coefficient is used for the display of the current page.
[0095] The application-level display coefficient can be used as the global display coefficient of the current application. For example, when the application is first run, the display adaptation amount obtained initially can be used to replace the adaptive display coefficient for all pages in the application. In the subsequent running of the application, when each page in the application is displayed, the operating environment can call the replaced adaptive display coefficient for adaptive display. Here, when the adaptive display coefficient is an application-level display coefficient, it is preferably applicable to the case where all pages in the application have the same size parameters.
[0096] The page-level display coefficient can be used as a local display coefficient of the current application. For example, each page in the application or a group of pages including multiple pages with the same size parameters can have the same adaptive display coefficient.
[0097] During the running of the application, when a single page is displayed, the display adaptation amount of the page can be calculated in real time and the display adaptation coefficient for the page in the running environment can be replaced with the calculated display adaptation amount, so that the page can be displayed based on the replaced display adaptation coefficient.
[0098] When the displayed page belongs to a specific page group, the display adaptation amount for the page group can be calculated when a page in the page group is displayed for the first time, and the display adaptation amount can be stored. When other pages in the page group are subsequently displayed, the display adaptation amount of the page group can be called up and used to replace the corresponding adaptive display coefficient in the operating environment to adapt the display of the page.
[0099] In another example, the standard unit conversion condition in the operating environment may not be modified, but the display adaptation amount may be directly used as the display adaptation parameter to display the display object on the screen. Specifically, when the display object is displayed on the screen, the size of the display object in the target size unit may be converted to the size in the screen size unit via the display adaptation amount, and then the size-converted display object is displayed on the screen. In this way, since the size-converted display object has the same size unit as the screen, it can be well adapted on the screen, that is, the display object can be fully displayed and fills the entire screen.
[0100] In addition, in step S104, when the standard unit conversion condition exists in the operating environment, the display adaptation amount may be used to replace the adaptation display coefficient in the standard unit conversion condition.
[0101] Here, in some examples, it is advantageous that the adapted display coefficient is an unrelated display coefficient, which means that the display coefficient is only associated with the adapted standard unit conversion condition, and does not involve other standard unit conversion conditions except the adapted standard unit conversion condition. Specifically, in the example shown in the above formula (5), by dynamically changing the DisplayMetrics.xdpi of the display object, the display object can calculate the size of the display object by using the replaced DisplayMetrics.xdpi value, so that only the display coefficient related to the current display object can be changed without changing other display coefficients in the running environment.
[0102] In other examples, the adaptive display coefficient in the adaptive standard unit conversion condition may be associated with a conversion rule between multiple units.
[0103] Specifically, still taking the Android system as an example, there may be standard unit conversion conditions in the system:
[0104] "case COMPLEX_UNIT_PX:return value;
[0105] case COMPLEX_UNIT_DIP:return value*metrics.density;
[0106] case COMPLEX_UNIT_SP:return value*metrics.scaledDensity",
[0107] When the target size unit is dp and the screen size unit is px, the adapted standard unit conversion condition for converting between the unit px and the unit dp can be extracted from the above standard unit conversion condition:
[0108] "case COMPLEX_UNIT_PX:return value;
[0109] case COMPLEX_UNIT_DIP:return value*metrics.density".
[0110] According to step S1022 described above, based on the standard unit conversion condition, the unit adaptation relationship between the unit px and the unit dp can be extracted, which can be shown in the following formula (6):
[0111] px unit size = dp unit size × density (6)
[0112] In formula (6), density is the adaptive display coefficient in the unit adaptation relationship. From this formula, it can be seen that if the size value of the px unit is to be equal to the actual value of the screen, when the size value of the px unit remains unchanged, in step S104, the adaptive display coefficient density of the current system needs to be dynamically changed, that is, the adaptive display coefficient density is replaced by the dynamically obtained display adaptation amount targetDensity.
[0113] In this case, as shown in the above standard unit conversion conditions, in the Android system, there are also associated standard unit conversion conditions associated with the above adaptation standard unit conversion conditions:
[0114] "case COMPLEX_UNIT_SP:return value*metrics.scaledDensity",
[0115] Combining the adaptation standard unit conversion conditions and the associated standard unit conversion conditions, it can be seen that density and scaledDensity are related display coefficients, for example, scaledDensity is equal to density or is positively correlated with density. When density changes, scaledDensity will also change accordingly. Therefore, in order to not affect the conversion relationship between the unit px and the unit sp during the conversion between the unit px and the unit dp, that is, in the process of changing density, the value of scaledDensity is not changed, it is necessary to transform scaledDensity accordingly during the adaptation process of the display object so that the conversion relationship between the unit px and the unit sp will not be changed together.
[0116] Specifically, there may be a unit conversion relationship between the unit px and the unit sp as shown in the following formula (7):
[0117] px unit size = sp unit size × scaledDensity (7)
[0118] In formula (7), scaledDensity is the display coefficient for conversion between px unit size and sp unit size, which is the associated display coefficient associated with the adapted display coefficient density. From this formula, it can be seen that when the associated display coefficient scaledDensity changes with the change of the adapted display coefficient density, the conversion relationship between the px unit size and the sp unit size will also change accordingly. In this case, in order to keep the conversion relationship between the px unit size and the sp unit size unchanged, the associated display coefficient scaledDensity can be controlled. Specifically, the new associated display coefficient (hereinafter also referred to as "associated adaptation amount") targetscaledDensity corresponding to the replaced adapted display coefficient (i.e., display adaptation amount targetDensity) can be determined by the following formula (8):
[0119] targetscaledDensity=targetDensity×(scaledDensity / density) (8)
[0120] In the above formula (8), the proportional relationship between the new associated display coefficient targetscaledDensity and the replaced adaptive display coefficient targetDensity is consistent with the proportional relationship between the original associated display coefficient scaledDensity and the display coefficient density, so that after replacing the adaptive display coefficient density with the display adaptation amount, the unit conversion relationship involving the associated display coefficient will not be changed.
[0121] Therefore, based on the above considerations, in an example where the unit adaptation relationship is determined based on the operating environment, after determining the display adaptation amount that satisfies the unit adaptation relationship according to the unit adaptation relationship, the screen adaptation method according to an embodiment of the present application may further include:
[0122] S105: Based on the unit adaptation relationship, determine the adaptation display coefficient in the unit adaptation relationship, and determine the associated adaptation coefficient associated with the adaptation display coefficient in the standard unit conversion condition of the operating environment.
[0123] In step S105, the adaptation display coefficient may refer to a coefficient used to characterize the proportional relationship between the target size unit and the screen size unit in the unit adaptation relationship between the target size unit and the screen size unit, such as the display coefficient density described above. The associated adaptation coefficient may refer to a display coefficient that has a predefined conversion relationship with the adaptation display coefficient in the standard unit conversion condition of the operating environment, such as the display coefficient scaledDensity described above.
[0124] S106: construct an associated adaptation relationship between the adaptive display coefficient and the associated adaptation coefficient according to the adaptive display coefficient and the associated adaptation coefficient and based on a standard unit conversion condition of the operating environment.
[0125] In step S106, the associated adaptation relationship between the adaptation display coefficient and the associated adaptation coefficient can be derived based on the standard unit conversion conditions of the operating environment. Here, the associated adaptation relationship can be the conversion relationship between the adaptation display coefficient and the associated adaptation coefficient predefined in the standard unit conversion conditions of the operating environment, such as the positive correlation between the display coefficient density and the display coefficient scaledDensity described above.
[0126] S107: Calculate the association adaptation amount according to the association adaptation relationship and the display adaptation amount, and replace the association adaptation coefficient with the association adaptation amount.
[0127] In step S107, the associated adaptation amount refers to the amount used to correct the associated adaptation coefficient according to the change of the display adaptation amount relative to the adapted display coefficient, such as the targetscaledDensity in equation (8) described above, so that the associated adaptation coefficient can be replaced by the associated adaptation amount to ensure that the conversion relationship between other associated size units is not affected in the process of adapting the target size unit and the screen size unit.
[0128] As an example, in the Android system, the screen adaptation method described above can be started by inheriting the system's Application class and overriding its onCreate method. Specifically, in the onCreate method, the initialization method of the AutoFit class, the core class for adaptation, can be called to start the execution of the entire screen adaptation method. In addition, when the application is run for the first time, the screen adaptation method described above can be automatically executed, and each subsequent time a display object is opened, screen adaptation can be automatically performed for the opened display object.
[0129] According to the screen adaptation method of the embodiment of the present application, the unit adaptation relationship between the display object to be displayed and the size unit of the screen can be determined, and the display adaptation amount that satisfies the unit adaptation relationship can be determined, so as to adapt the display object to be displayed on the screen based on the display adaptation amount. According to this method, the display object can be adapted to be displayed on screens of different specifications based on a single set of layout files, without the need to write multiple sets of layout files for each screen, thereby improving development efficiency, and being applicable to any existing model or new model of screen that will appear in the future, with strong universality.
[0130] In addition, since the screen adaptation method according to the embodiment of the present application can be applied to any type of display objects, such as the page background image of a UI page, UI elements, the spacing between elements, page borders, etc., different types of display objects can be displayed based on the same adaptation method, thereby maintaining the relative position relationship between the display objects. For example, the preset positioning relationship between the page background image of a UI page and the UI elements can be maintained, so that the UI elements precisely coincide with the specified positions in the page background image.
[0131] In addition, according to the screen adaptation method of the embodiment of the present application, determining the target size unit of the display object to be displayed and the screen size unit of the screen may also include the following steps:
[0132] S1014, monitoring the actions of the display object, and identifying whether the display object has an adaptation interface when monitoring that the display object performs a new action;
[0133] S1015: When it is identified that the display object has an adaptation interface, determine a target size unit of the display object to be displayed and a screen size unit of the screen.
[0134] In step S1014 , the action of displaying the object may refer to an operation related to the display of the display object, for example, it may include opening, updating, moving or scaling the display object.
[0135] The adaptation interface may be an interface used to identify whether a display object needs to be adapted. Each display object may be provided with a corresponding adaptation interface.
[0136] When a display object is monitored to perform a new action, it can be identified whether the display object has an adaptation interface. As an example, in the Android system, the lifecycle callback of the display object can be registered in the initialization of the core class AutoFit created for the screen adaptation method mentioned above, and the Application object can call the registerActivityLifecycleCallbacks(ActivityLifecycleCallbacks) method in the running environment to pass the lifecycle callback of each display object monitored by the implemented ActivityLifecycleCallbacks to the application's Application object for monitoring. In this way, when a new display object is created, the implemented ActivityLifecycleCallbacks will be called back.
[0137] If it is identified that the display object has an adaptation interface, the screen adaptation process can be performed in step S1015. If it is not identified that the display object has an adaptation interface, it can be considered that the current display object does not need to be adapted for display, and the display object can be directly displayed on the screen.
[0138] Here, as an example, the adaptation interface may predefine an adaptation reference of the display object and an object size parameter of the display object corresponding to the adaptation reference.
[0139] The adaptation reference may refer to a size dimension reference for adapting the display of a display object, which may include taking the first dimension of the display object as a reference or taking the second dimension of the display object as a reference, the first dimension and the second dimension being the dimensions of the display object in different directions, for example, the first dimension and the second dimension may be the width and height of the display object, respectively, however, the present application is not limited thereto, the first dimension and the second dimension may also be defined as needed, for example, at least one of the first dimension and the second dimension may be the diagonal dimension of the display object.
[0140] When it is recognized that the display object has an adaptation interface, the predefined information in the adaptation interface can be retrieved to execute the screen adaptation process. As an example, in the Android system, in the onActivityCreated(Activity activity,Bundle savedInstanceState) method in the listening class, it can be determined whether the current active display object has an adaptation interface. If it has an adaptation interface, the adaptation reference and object size parameters set for the current display object can be obtained through the adaptation interface, such as the total design width of the design drawing (when the adaptation reference is width) or the total design height (when the adaptation reference is height). When the display object is initialized, the return value of the predefined information in the adaptation interface can be automatically obtained to modify the size parameters of the current display object.
[0141] In the above method of the embodiment of the present application, an adaptation interface is set for the display object and the action of each display object is monitored, so that some display objects of the existing application can be modified. Specifically, in an application that has been created or installed and used, the display objects already existing in the application (for example, the old UI page) may not have the need for adaptive display, and when updating the application, the newly added display object (for example, the new UI page) may need adaptive display, therefore, an adaptation interface can be set for the newly added display object, while the previously existing display object does not have an adaptation interface. When the display object in the application is monitored to perform a new action, it can be first determined whether the display object performing the action has an adaptation interface, that is, it can be distinguished whether the display object is a previously existing display object that does not need to be adapted for display, or a newly added display object that needs to be adapted for display, thereby, the display object can be displayed accordingly according to whether it has an adaptation interface, that is, adaptive display or direct display is performed.
[0142] Based on the same application concept, the embodiment of the present application also provides a screen adaptation device for a display object. The screen adaptation device for a display object is mainly used to execute the screen adaptation method for a display object provided in the above content of the embodiment of the present application. The screen adaptation device for a display object provided in the embodiment of the present application is specifically introduced below.
[0143] Figure 2 The schematic diagram of the structure of a screen adaptation device for displaying an object provided by an embodiment of the present application is shown. The screen adaptation device for displaying an object may include a unit determination unit 10, an adaptation relationship determination unit 20, an adaptation amount determination unit 30 and an adaptation display unit 40, wherein:
[0144] A unit determination unit 10, used to determine a target size unit of a display object to be displayed and a screen size unit of a screen;
[0145] An adaptation relationship determining unit 20, configured to determine a unit adaptation relationship between the target size unit and the screen size unit based on the target size unit and the screen size unit;
[0146] The adaptation amount determination unit 30 is used to determine the display adaptation amount that satisfies the unit adaptation relationship according to the unit adaptation relationship;
[0147] The display adaptation unit 40 is used to adapt the display object on the screen based on the display adaptation amount.
[0148] In the screen adaptation device for display objects according to the embodiment of the present application, the unit adaptation relationship between the display object to be displayed and the size unit of the screen can be used to determine the display adaptation amount that satisfies the unit adaptation relationship, so that the display object can be adapted and displayed on the screen based on the display adaptation amount. According to this method, the display object can be adapted and displayed on screens of different specifications based on a single set of layout files, without the need to write multiple sets of layout files for each screen, thereby improving development efficiency. It is also applicable to any existing model or new model of screen that will appear in the future, and has strong universality.
[0149] Further, the unit determination unit 10 determines the target size unit of the display object by: acquiring a layout file of the display object; and extracting the target size unit from the layout file.
[0150] Furthermore, the screen adaptation device for displaying an object may also include a layout unit, which generates a layout file in the following manner: obtaining object size parameters and original size units of the display object; replacing the original size units with target size units to obtain the layout size of the display object composed of the object size parameters and the target size units; and generating a layout file for the display object based on the layout size.
[0151] Further, the object size parameter includes a first dimension size parameter and a second dimension size parameter; the layout size includes a first dimension layout size and a second dimension layout size. The adaptation relationship determination unit 20 is also used to: replace the original size unit of the first dimension size parameter with the target size unit to obtain the first dimension layout size composed of the first dimension size parameter and the target size unit; based on the target size unit and the original size unit, perform scroll layout wrapping on the second dimension size parameter of the display object to obtain the second dimension layout size of the display object.
[0152] Furthermore, the adaptation relationship determination unit 20 is also used to: determine the adaptation standard unit conversion conditions associated with the target size unit and the screen size unit in the standard unit conversion conditions of the operating environment based on the target size unit and the screen size unit; and determine the unit adaptation relationship based on the adaptation standard unit conversion conditions.
[0153] Furthermore, the adaptation amount determination unit 30 is further used to: obtain object size parameters of the display object and screen size parameters of the screen; apply the object size parameters and the screen size parameters to the unit adaptation relationship to solve the display adaptation amount that satisfies the unit adaptation relationship.
[0154] Furthermore, the display adaptation unit 40 is further used to: replace the display adaptation coefficient corresponding to the display adaptation amount in the operating environment with the display adaptation amount; and adaptively display the display object on the screen based on the replaced display adaptation coefficient and the layout file of the display object.
[0155] Furthermore, the adapted display coefficient includes an application-level display coefficient or a page-level display coefficient. The application-level display coefficient is used for displaying all pages in the application, and the page-level display coefficient is used for displaying the current page.
[0156] Furthermore, the unit determination unit 10 is also used to: monitor the actions of the display object, and when monitoring the display object to perform a new action, identify whether the display object has an adaptation interface; when identifying that the display object has an adaptation interface, determine the target size unit of the display object to be displayed and the screen size unit of the screen.
[0157] Furthermore, the adaptation interface predefines an adaptation benchmark of the display object and an object size parameter of the display object corresponding to the adaptation benchmark. The adaptation benchmark includes taking the first dimension size of the display object as a benchmark or taking the second dimension size of the display object as a benchmark, and the first dimension size and the second dimension size are the sizes of the display object in different directions.
[0158] Further, the display object includes one or more of a user interface element for generating a user interface page, a spacing between user interface elements, a user interface page border, a user interface page background image, and a position of the user interface page background image. The target size unit includes any one of points, pixels, device-independent pixels, scalable pixels, inches, and millimeters. The screen size unit includes any one of points, pixels, device-independent pixels, scalable pixels, inches, and millimeters.
[0159] The implementation principle and technical effects of the device provided in the embodiments of the present application are the same as those of the aforementioned method embodiments. For the sake of brief description, for matters not mentioned in the device embodiments, reference may be made to the corresponding contents in the aforementioned method embodiments.
[0160] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can all refer to the corresponding processes in the above method embodiments, and will not be repeated here. The screen adaptation device for display objects provided in the embodiments of the present application has the same technical features as the screen adaptation method for display objects provided in the above embodiments, so it can also solve the same technical problems and achieve the same technical effects.
[0161] Based on the same application concept, the embodiment of the present application further provides an electronic device, specifically, referring to Figure 3The electronic device 100 may include a processor 101, a memory 102 and a bus. The processor 101 and the memory 102 communicate with each other through the bus. The memory 102 stores a computer program executable by the processor 101. When the processor 101 executes the computer program, the steps of the screen adaptation method for the display object as described above are implemented. The specific implementation method can be found in the method embodiment, which will not be repeated here.
[0162] Specifically, the processor 101 and the memory 102 can be general-purpose processors and memories, which are not specifically limited here. When the processor 101 runs the computer program stored in the memory 102, the screen adaptation method of the display object can be executed.
[0163] Corresponding to the screen adaptation method for the above-mentioned display object, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is called and executed by a processor, the computer program prompts the processor to execute the steps of the screen adaptation method for the above-mentioned display object. The specific implementation method can be found in the method embodiment, which will not be repeated here.
[0164] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0165] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0166] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0167] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0168] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0169] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A screen adaptation method for displaying an object, characterized in that: The screen adaptation method comprises: Determine a target size unit of a display object to be displayed and a screen size unit of the screen; Based on the target size unit and the screen size unit, determining a unit adaptation relationship between the target size unit and the screen size unit; the unit adaptation relationship represents a conversion correspondence between the target size unit and the screen size unit; Substituting the acquired unitless object size parameter of the display object and the screen size parameter of the screen into a unit adaptation relationship, and determining a display adaptation amount that satisfies the unit adaptation relationship; Based on the display adaptation amount, the adaptation display parameters in the unit adaptation relationship are modified, a new unit adaptation relationship is established, and the display object is adaptively displayed on the screen according to the new unit adaptation relationship.
2. The screen adaptation method according to claim 1, characterized in that: The target size units for the display object are determined by: Obtaining a layout file of the display object; The target size unit is extracted from the layout file.
3. The screen adaptation method according to claim 2, characterized in that: The layout file is generated in the following way: Get the object size parameters and original size units of the display object; Replace the original size unit with the target size unit to obtain the layout size of the display object consisting of the object size parameter and the target size unit; Based on the layout size, a layout file of the display object is generated.
4. The screen adaptation method according to claim 3, characterized in that: The object size parameters include first dimension size parameters and second dimension size parameters; the layout size includes first dimension layout size and second dimension layout size, Replacing the original size unit with the target size unit to obtain a layout size of the display object consisting of the object size parameter and the target size unit includes: Replacing the original size unit of the first dimension size parameter with the target size unit to obtain the first dimension layout size consisting of the first dimension size parameter and the target size unit; Based on the target size unit and the original size unit, a scrolling layout wrapping is performed on the second dimension size parameter of the display object to obtain the second dimension layout size of the display object.
5. The screen adaptation method according to claim 1, characterized in that: Determining a unit adaptation relationship between the target size unit and the screen size unit based on the target size unit and the screen size unit includes: Based on the target size unit and the screen size unit, determining an adaptation standard unit conversion condition associated with the target size unit and the screen size unit in the standard unit conversion condition of the operating environment; Based on the adaptation standard unit conversion condition, the unit adaptation relationship is determined.
6. The screen adaptation method according to claim 1, characterized in that: Adapting and displaying the display object on the screen based on the display adaptation amount includes: Using the display adaptation amount, replacing the adaptation display coefficient corresponding to the display adaptation amount in the operating environment; The display object is adaptively displayed on the screen based on the replaced adaptive display coefficient and the layout file of the display object.
7. The screen adaptation method according to claim 6, characterized in that: The adaptive display coefficient includes an application-level display coefficient or a page-level display coefficient. The application-level display coefficient is used for displaying all pages in an application, and the page-level display coefficient is used for displaying a current page.
8. The screen adaptation method according to claim 1, characterized in that: Determine the target size unit of the display object to be displayed and the screen size unit of the screen, including: Monitoring the actions of the display object, and identifying whether the display object has an adaptation interface when monitoring the display object performing a new action; In the case where it is identified that the display object has an adaptation interface, a target size unit of the display object to be displayed and a screen size unit of the screen are determined.
9. The screen adaptation method according to claim 8, characterized in that: The adaptation interface predefines an adaptation reference of the display object and an object size parameter of the display object corresponding to the adaptation reference; the adaptation reference includes taking the first dimension size of the display object as a reference or taking the second dimension size of the display object as a reference, and the first dimension size and the second dimension size are the sizes of the display object in different directions.
10. The screen adaptation method according to any one of claims 1 to 9, characterized in that: The display object includes one or more of a user interface element for generating a user interface page, a spacing between user interface elements, a user interface page border, a user interface page background image, and a position of the user interface page background image; The target size unit includes any one of points, pixels, device-independent pixels, scalable pixels, inches, and millimeters; The screen size unit includes any one of points, pixels, device-independent pixels, scalable pixels, inches, and millimeters.
11. A screen adaptation device for displaying an object, characterized in that: The screen adaptation device comprises: a unit determination unit, determining a target size unit of a display object and a screen size unit of a screen; an adaptation relationship determining unit, which determines a unit adaptation relationship between the target size unit and the screen size unit based on the target size unit and the screen size unit; the unit adaptation relationship represents a conversion correspondence between the target size unit and the screen size unit; an adaptation amount determining unit, which brings the acquired unitless object size parameter of the display object and the screen size parameter of the screen into a unit adaptation relationship, and determines a display adaptation amount that satisfies the unit adaptation relationship; The display adaptation unit modifies the display adaptation parameters in the unit adaptation relationship based on the display adaptation amount, establishes a new unit adaptation relationship, and adaptively displays the display object on the screen according to the new unit adaptation relationship.
12. An electronic device, characterized in that: The electronic device comprises a processor and a memory, The memory stores a computer program executable by the processor, and the processor implements the steps of the screen adaptation method according to any one of claims 1 to 10 when executing the computer program.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the screen adaptation method according to any one of claims 1 to 10 are executed.
Citation Information
Patent Citations
Screen adaptation method for Android system SDK development and related device
CN112596842A
