CN114647393A - Screen adaptation method, device, server and storage medium - Google Patents
Screen adaptation method, device, server and storage medium Download PDFInfo
- Publication number
- CN114647393A CN114647393A CN202210209848.XA CN202210209848A CN114647393A CN 114647393 A CN114647393 A CN 114647393A CN 202210209848 A CN202210209848 A CN 202210209848A CN 114647393 A CN114647393 A CN 114647393A
- Authority
- CN
- China
- Prior art keywords
- displayed
- screen
- view
- sub
- original
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 41
- 230000006978 adaptation Effects 0.000 title claims abstract description 22
- 238000013461 design Methods 0.000 claims abstract description 43
- 238000012545 processing Methods 0.000 claims description 10
- 238000011161 development Methods 0.000 abstract description 7
- 230000000694 effects Effects 0.000 abstract description 6
- 238000012423 maintenance Methods 0.000 abstract description 6
- 238000005516 engineering process Methods 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 15
- 238000004590 computer program Methods 0.000 description 10
- 230000006870 function Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000003044 adaptive effect Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000013467 fragmentation Methods 0.000 description 1
- 238000006062 fragmentation reaction Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/14—Digital output to display device ; Cooperation and interconnection of the display device with other functional units
- G06F3/1407—General aspects irrespective of display type, e.g. determination of decimal point position, display with fixed or driving decimal point, suppression of non-significant zeros
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The present disclosure relates to the field of internet technologies, and in particular, to a screen adapting method, apparatus, server, and storage medium. The screen adaptation method comprises the following steps: creating a user-defined control; when the child view to be displayed is initialized, rewriting an original constructor of the custom control based on the size information of the design draft corresponding to the child view to be displayed and the screen resolution information of the display screen; and calculating the display size of the sub-view to be displayed by using the rewritten custom control, and displaying the sub-view to be displayed based on the display size. The method has the advantages of good screen adaptation effect, low development and maintenance cost and low code and intrusion.
Description
Technical Field
The present disclosure relates to the field of internet technologies, and in particular, to a screen adapting method, apparatus, server, and storage medium.
Background
With the increase of terminal equipment manufacturers, the models are diversified continuously, so that the fragmentation of the screen of the terminal equipment is serious. In order to achieve the optimal visual effect, screen adaptation work of various machine types needs to be confronted in the development process. At present, screen adaptation mainly solves the adaptation problem of the horizontal view, and mainly comprises the following steps: when the logical screen width of the terminal device is smaller than the design width, the UI overlapping or the cut-off scene may occur in the landscape view.
In the related technology, the method for solving the problem of adapting the transverse view mainly comprises the step of carrying out screen adaptation by dynamically setting layout parameters of codes, and the method is relatively complicated, increases development and maintenance cost, has certain intrusiveness on business logic codes, cannot perfectly restore design manuscripts on all terminal equipment, and has poor adaptation effect.
Disclosure of Invention
The present disclosure provides a screen adaptation method, an apparatus, a server and a storage medium, so as to solve at least the problems of high development and maintenance costs, certain intrusiveness to business logic codes, and poor adaptation effect of the screen adaptation method in the related art.
The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a screen adapting method, including:
creating a custom control, wherein the custom control inherits any layout container;
when the child view to be displayed is initialized, rewriting the original constructor of the custom control based on the size information of the design draft corresponding to the child view to be displayed and the screen resolution information of the display screen;
and calculating the display size of the sub-view to be displayed by using the rewritten custom control, and displaying the sub-view to be displayed based on the display size.
Optionally, the layout container includes, but is not limited to, a frame layout, a linear layout, and an opposite layout.
Optionally, the rewriting the constructor of the custom control based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen includes:
acquiring an original configuration object corresponding to an original context object of the original constructor;
creating a new configuration object based on the original configuration object, and calculating a screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen;
creating a new context object based on the new configuration object;
replacing the original context object with the new context object.
Optionally, the calculating the screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen includes:
the screen density parameter of the new configuration object is (screen resolution width (px)/design draft width (dp)) x 160.
Optionally, the calculating, by using the rewritten custom control, the display size of the sub-view to be displayed includes:
and calculating the display size of the sub-view to be displayed by utilizing the screen density parameter associated with the new context object in the constructor of the rewritten custom control.
Optionally, the display size includes: width, height, and spacing of sub-views to be displayed.
According to a second aspect of the embodiments of the present disclosure, there is provided a screen adapting apparatus including:
the creating unit is configured to create a custom control, and the custom control inherits any layout container;
the processing unit is configured to rewrite the original constructor of the custom control based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen when the sub-view to be displayed is initialized;
and the display unit is configured to calculate the display size of the to-be-displayed sub-view by using the rewritten custom control and display the to-be-displayed sub-view based on the display size.
Optionally, the layout container includes, but is not limited to, a frame layout, a linear layout, and an opposite layout.
Optionally, the processing unit includes:
an obtaining subunit, configured to obtain an original configuration object corresponding to an original context object of the original constructor;
the calculation subunit is configured to create a new configuration object based on the original configuration object, and calculate a screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen;
a creating subunit configured to create a new context object based on the new configuration object;
a replacement subunit configured to replace the original context object with the new context object.
Optionally, the calculating subunit is configured to set a new configuration object to have a screen density parameter (screen resolution width (px)/design draft width (dp)) x 160.
Optionally, the display unit is configured to calculate a display size of the sub-view to be displayed by using a screen density parameter associated with a new context object in the constructor of the rewritten custom control.
Optionally, the display size includes: width, height, and spacing of sub-views to be displayed.
According to a third aspect of the present application, there is provided a server comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the screen adaptation method of any of claims 1 to 6.
According to a fourth aspect of the present application, there is provided a storage medium having instructions which, when executed by a processor of a server, enable the server to perform the screen adaptation method according to the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
in some or related embodiments, a custom control is created, then when the sub-view to be displayed is initialized, the original constructor of the custom control is rewritten based on the size information of the design corresponding to the sub-view to be displayed and the screen resolution information of the display screen, the display size of the sub-view to be displayed is calculated by using the rewritten custom control, and the sub-view to be displayed is displayed based on the display size. Therefore, in the embodiment of the present disclosure, when the sub-view to be displayed is initialized, specifically, the sub-view to be displayed is displayed by using "the custom control after the original constructor is rewritten based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen", so that the sub-view to be displayed can be adapted to the display screen, and the adaptation effect is good. In addition, in the embodiment of the disclosure, when the screen is displayed in an adaptive manner, specifically, the custom control in the disclosure is used to wrap one layer on the outermost layer of the xml layout file normally written according to the size information of the design draft, and it is not necessary to dynamically set layout parameters in the business logic code or additionally write a plurality of sets of xml layout files adapted to different screen sizes, so that the development and maintenance cost is reduced, and low-code and low-intrusion are realized.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flow diagram illustrating a screen adaptation method according to an exemplary embodiment;
FIG. 2 is a block diagram of a screen adapting apparatus according to an exemplary embodiment;
FIG. 3 is a block diagram of a screen adapting device according to an exemplary embodiment
FIG. 4 is a block diagram illustrating a server in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating a screen adapting method according to an exemplary embodiment, which is performed by a screen adapting apparatus, as shown in fig. 1, and may include the steps of:
in step S11, a custom control is created.
In some embodiments, the custom control can inherit any layout container, including but not limited to FrameLayout (framework layout), Linear layout, and RelativeLayout (relative layout).
In step S12, when the sub View (View) to be displayed is initialized, the original constructor of the custom control is rewritten based on the size information of the design corresponding to the sub View to be displayed and the screen resolution information of the display screen.
The size information of the design document may be, for example, a design document width, and the design document width may be, for example, 360 dp.
In some embodiments, a developer typically writes an xml layout file for page display according to the size information of the design draft, and then the custom control may parse and load the xml layout file to display the sub views to be displayed based on the size information of the design draft. However, it should be noted that there may be a mismatch between the logical screen width of a part of the terminal device display screen (where the logical screen width (dp) is the screen resolution width (px)/(desireddpi parameter/160)) and the size information of the design draft, and based on this, if the xml layout file is loaded by parsing using the original custom control each time the sub View to be displayed is displayed, a problem that the displayed sub View is not adapted to the display screen, such as a UI overlapping or a cut scene, may occur inevitably.
Thus, in some embodiments, since each child View is created by using a Context object (Context object) in the original constructor of the custom control (i.e., the parent layout) during the parsing loading of the xml layout file, and since the Context object of the custom control can be dynamically replaced when the child View is initialized, in the present disclosure, when the child View to be displayed is initialized by using the xml layout file, a new Context object adapted to the screen resolution information of the current display screen can be created based on the size information of the design corresponding to the child View to be displayed and the screen resolution information of the display screen, and the original Context object in the original constructor of the custom control can be replaced by using the new Context object to rewrite the original constructor of the custom control. The rewritten custom control is determined based on the screen resolution information of the current display screen, so that when the rewritten custom control is subsequently used for displaying the sub-View to be displayed based on the xml layout file, the View display size of the sub-View can be automatically controlled (such as the View display size of the automatically isometric scaling sub-View), and the View display size of the sub-View can be always self-adapted to the current display screen.
Further, in some embodiments, the method for rewriting the constructor of the custom control based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen may include the following steps:
in step S121, an original Configuration object (Configuration object) corresponding to the original Context object of the original constructor is acquired.
Wherein, in some embodiments, the Configuration object Configuration of a context may be obtained by context.
For example, in some embodiments, assuming that the original Context object of the original constructor is contextA, the Configuration object Configuration a of contextA may be obtained through contextA.
In step S122, a new Configuration object is created based on the original Configuration object, and a densityDpi parameter (i.e., a screen density parameter) of the new Configuration object is calculated based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen.
In some embodiments, a new Configuration object may be created through new Configuration (Configuration).
For example, in some embodiments, a new Configuration object Configuration b may be created by new Configuration (Configuration a).
And, in some embodiments, since the densityDpi attribute in the Configuration object determines the screen density parameter of the DisplayMetrics object associated with the generated Context corresponding Resources object, wherein the screen density parameter may affect dp, sp conversion px, and drawable picture loading, etc. Therefore, when a new Configuration object is created, it is necessary to calculate the densityDpi parameter of the new Configuration object based on the size information of the design draft corresponding to the sub-View to be displayed and the screen resolution information of the display screen, so that after the original Configuration function of the custom control is rewritten based on the calculated densityDpi parameter of the new Configuration object, the rewritten custom control can enable self-adaptive display of the sub-View.
In some embodiments, the method for calculating the densityDpi parameter of the new Configuration object based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen may include:
the densityDpi parameter of the new Configuration object is (screen resolution width (px)/design draft width (dp)) x 160.
In step S123, a new Context object is created based on the new Configuration object.
In some embodiments, a Configuration parameter may be passed through a Context Configuration Context interface to create a Configuration-specific (i.e., specifying a densityDpi parameter) Context object.
For example, in some embodiments, assuming that the original Context object is configa and the new configuration object is configuration b, a new Context object, ContextB, may be created based on configuration b by configa.
In step S124, the original Context object is replaced with the new Context object.
Among other things, in some embodiments, rewriting the original constructor of a custom control may be accomplished by replacing the original Context object with a new Context object. Moreover, it should be noted that, in some embodiments, when a new Context object replaces an original Context object, a corresponding Resources object may also be determined by the new Context object.
In step S13, the rewritten custom control is used to calculate the display size of the sub View to be displayed, and the sub View to be displayed is displayed based on the display size.
In some embodiments, the method for calculating the display size of the sub View to be displayed by using the rewritten custom control may include: and calculating the display size of the sub-View to be displayed by using the screen density parameter associated with the new Context object in the constructor of the rewritten custom control. Also, since the custom control in the present disclosure is rewritten based on the screen resolution information of the display screen, calculating the display size of the sub View to be displayed using the rewritten custom control should be adapted to the display size of the current screen.
And, in some embodiments, the display size may include the width, height, and spacing of the sub-views to be displayed.
In summary, in some or related embodiments, a custom control is created, then when the sub View to be displayed is initialized, the original constructor of the custom control is rewritten based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen, the display size of the sub View to be displayed is calculated by using the rewritten custom control, and the sub View to be displayed is displayed based on the display size. Therefore, in the embodiment of the present disclosure, when the sub View to be displayed is initialized, the sub View to be displayed is specifically displayed by using "the custom control after the original constructor is rewritten based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen", so that the sub View to be displayed can be adapted to the display screen, and the adaptation effect is good. In addition, in the embodiment of the disclosure, when the screen is adaptively displayed, specifically, the custom control in the disclosure is used to wrap one layer on the outermost layer of the xml layout file normally written according to the size information of the design draft, and it is not necessary to dynamically set the layout parameters in the business logic code or additionally write a plurality of sets of xml layout files adapted to different screen sizes, so that the development and maintenance cost is reduced, and low-code and low-intrusion are realized.
Fig. 2 is a block diagram illustrating a screen adapting apparatus according to an exemplary embodiment. Referring to fig. 2, the screen adapting apparatus includes:
the creating unit 201 is configured to create a custom control, and the custom control inherits any layout container;
the processing unit 202 is configured to rewrite an original constructor of the custom control based on size information of a design draft corresponding to the sub-View to be displayed and screen resolution information of a display screen when the sub-View to be displayed is initialized;
and the display unit 203 is configured to calculate the display size of the sub-View to be displayed by using the rewritten custom control, and display the sub-View to be displayed based on the display size.
Optionally, layout containers include, but are not limited to, FrameLayout, LinearLayout, RelativeLayout.
Alternatively, fig. 3 is a block diagram illustrating a screen adapting apparatus according to an exemplary embodiment. Referring to fig. 2, the processing unit 202 includes:
an obtaining subunit 2021 configured to obtain an original Configuration object corresponding to the original Context object of the original constructor;
a calculating subunit 2022 configured to create a new Configuration object based on the original Configuration object, and calculate a densityDpi parameter of the new Configuration object based on the size information of the design draft corresponding to the child View to be displayed and the screen resolution information of the display screen;
a creation subunit 2023 configured to create a new Context object based on the new Configuration object;
a replace subunit 2024 configured to replace the original Context object with the new Context object.
Optionally, the calculating unit 2022 is configured to set the densityDpi parameter of the new Configuration object to (screen resolution width (px)/design draft width (dp)) x 160.
Optionally, the display unit 203 is configured to calculate a display size of the sub View to be displayed by using a screen density parameter associated with a new Context object in the constructor of the rewritten custom control.
Optionally, the display size includes: the width, height and spacing of the sub-views to be displayed.
In summary, in some or related embodiments, a custom control is created, then when the sub View to be displayed is initialized, the original constructor of the custom control is rewritten based on the size information of the design corresponding to the sub View to be displayed and the screen resolution information of the display screen, the display size of the sub View to be displayed is calculated by using the rewritten custom control, and the sub View to be displayed is displayed based on the display size. Therefore, in the embodiment of the present disclosure, when the sub View to be displayed is initialized, the sub View to be displayed is specifically displayed by using "the custom control after the original constructor is rewritten based on the size information of the design draft corresponding to the sub View to be displayed and the screen resolution information of the display screen", so that the sub View to be displayed can be adapted to the display screen, and the adaptation effect is good. In addition, in the embodiment of the disclosure, when the screen is adaptively displayed, specifically, the custom control in the disclosure is used to wrap one layer on the outermost layer of the xml layout file normally written according to the size information of the design draft, and it is not necessary to dynamically set the layout parameters in the business logic code or additionally write a plurality of sets of xml layout files adapted to different screen sizes, so that the development and maintenance cost is reduced, and low-code and low-intrusion are realized.
FIG. 4 is a block diagram illustrating a server in accordance with an example embodiment. As shown in fig. 4, the server includes: a memory 401 and a processor 402. In addition, the server also includes necessary components such as a power component 403, a communication component 404, and the like.
The memory 401 is used for storing computer programs and may be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device.
The memory 401 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
A communication component 404 for data transmission with other devices.
The processor 402 may execute computer instructions stored in the memory 401 for performing the above-described methods.
Correspondingly, the embodiment of the application also provides a computer readable storage medium storing the computer program. The computer-readable storage medium stores a computer program that, when executed by one or more processors, causes the one or more processors to perform the steps in the method embodiment of fig. 1.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above are merely exemplary embodiments of the present application and are intended to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (10)
1. A screen adaptation method, comprising:
creating a custom control which inherits any layout container;
when the child view to be displayed is initialized, rewriting the original constructor of the custom control based on the size information of the design draft corresponding to the child view to be displayed and the screen resolution information of the display screen;
and calculating the display size of the sub-view to be displayed by using the rewritten custom control, and displaying the sub-view to be displayed based on the display size.
2. The method of claim 1, wherein the layout container includes, but is not limited to, a frame layout, a linear layout, an opposite layout.
3. The method according to claim 1, wherein the rewriting the constructor of the custom control based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen comprises:
acquiring an original configuration object corresponding to an original context object of the original constructor;
creating a new configuration object based on the original configuration object, and calculating a screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen;
creating a new context object based on the new configuration object;
replacing the original context object with the new context object.
4. The method according to claim 3, wherein the calculating the screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen comprises:
the screen density parameter of the new configuration object is (screen resolution width (px)/design draft width (dp)) x 160.
5. The method according to claim 3, wherein the calculating the display size of the sub-view to be displayed by using the rewritten custom control comprises:
and calculating the display size of the sub-view to be displayed by utilizing the screen density parameter associated with the new context object in the constructor of the rewritten custom control.
6. The method of claim 5, wherein the display size comprises: width, height, and spacing of sub-views to be displayed.
7. A screen adapting device, comprising:
the creating unit is configured to create a custom control, and the custom control inherits any layout container;
the processing unit is configured to rewrite the original constructor of the custom control based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen when the sub-view to be displayed is initialized;
and the display unit is configured to calculate the display size of the to-be-displayed sub-view by using the rewritten custom control and display the to-be-displayed sub-view based on the display size.
8. The apparatus of claim 7, wherein the processing unit comprises:
an obtaining subunit, configured to obtain an original configuration object corresponding to an original context object of the original constructor;
the calculating subunit is configured to create a new configuration object based on the original configuration object, and calculate a screen density parameter of the new configuration object based on the size information of the design draft corresponding to the sub-view to be displayed and the screen resolution information of the display screen;
a creating subunit configured to create a new context object based on the new configuration object;
a replacement subunit configured to replace the original context object with the new context object.
9. A server, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the screen adaptation method of any of claims 1 to 6.
10. A storage medium in which instructions, when executed by a processor of a server, enable the server to perform the screen adaptation method of any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210209848.XA CN114647393A (en) | 2022-03-04 | 2022-03-04 | Screen adaptation method, device, server and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210209848.XA CN114647393A (en) | 2022-03-04 | 2022-03-04 | Screen adaptation method, device, server and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114647393A true CN114647393A (en) | 2022-06-21 |
Family
ID=81994430
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210209848.XA Pending CN114647393A (en) | 2022-03-04 | 2022-03-04 | Screen adaptation method, device, server and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114647393A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118733184A (en) * | 2024-09-04 | 2024-10-01 | 荣耀终端有限公司 | Method for displaying interface and electronic equipment |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0694834A1 (en) * | 1994-06-30 | 1996-01-31 | Canon Kabushiki Kaisha | User interface for multiple child windows |
CN107015793A (en) * | 2016-12-12 | 2017-08-04 | 阿里巴巴集团控股有限公司 | Design original text adaptation method, apparatus and system |
CN108427546A (en) * | 2018-05-03 | 2018-08-21 | 深圳Tcl新技术有限公司 | Full screen adaptation method, display device and the storage medium of display device |
CN110597579A (en) * | 2019-07-08 | 2019-12-20 | 深圳大趋智能科技有限公司 | Android system-based custom control generation method, apparatus, device and medium |
CN113867701A (en) * | 2020-06-30 | 2021-12-31 | 武汉斗鱼鱼乐网络科技有限公司 | Container object instantiation method and device, storage medium and electronic equipment |
-
2022
- 2022-03-04 CN CN202210209848.XA patent/CN114647393A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP0694834A1 (en) * | 1994-06-30 | 1996-01-31 | Canon Kabushiki Kaisha | User interface for multiple child windows |
CN107015793A (en) * | 2016-12-12 | 2017-08-04 | 阿里巴巴集团控股有限公司 | Design original text adaptation method, apparatus and system |
CN108427546A (en) * | 2018-05-03 | 2018-08-21 | 深圳Tcl新技术有限公司 | Full screen adaptation method, display device and the storage medium of display device |
CN110597579A (en) * | 2019-07-08 | 2019-12-20 | 深圳大趋智能科技有限公司 | Android system-based custom control generation method, apparatus, device and medium |
CN113867701A (en) * | 2020-06-30 | 2021-12-31 | 武汉斗鱼鱼乐网络科技有限公司 | Container object instantiation method and device, storage medium and electronic equipment |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118733184A (en) * | 2024-09-04 | 2024-10-01 | 荣耀终端有限公司 | Method for displaying interface and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110058856A (en) | Page configuration method and device | |
US8959426B1 (en) | Loading customer-supplied network page generation code | |
CN110362547A (en) | Coding, parsing, storage method and the device of journal file | |
WO2013109858A1 (en) | Design canvas | |
CN106919620B (en) | Single page processing method and device | |
CN112235132A (en) | Method, device, medium and server for dynamically configuring service | |
CN114647393A (en) | Screen adaptation method, device, server and storage medium | |
CN115841236A (en) | Business modeling method, device and medium for realizing quick response | |
CN112016267A (en) | Icon font processing method and device and storage medium | |
CN116301856B (en) | Design method, device, equipment and medium of visual form designer | |
CN106610830B (en) | Page element drag-and-drop method and device | |
CN112527424A (en) | Control method and device for popup window | |
CN116578331A (en) | Service version management method, device and medium based on Web interface | |
CN114281463B (en) | Form interface format configuration and interface display method, device and medium | |
CN110968373A (en) | Page switching implementation method and device, storage medium and processor | |
CN111651160B (en) | Plug-in construction and webpage design method and device | |
CN114254229A (en) | Webpage rendering method and device | |
US9552347B1 (en) | Data grid cell styling systems and methods | |
CN110020285B (en) | Histogram processing method and device | |
CN111125565A (en) | Method and equipment for inputting information in application | |
CN112181396A (en) | RN code automatic generation system, method, equipment and medium | |
CN113076161B (en) | Page display method, device, storage medium and equipment | |
CN116757169B (en) | Method, equipment and medium for generating highway maintenance metering payment report | |
CN114895995B (en) | Control view generation method and device, electronic equipment and readable medium | |
CN110825450B (en) | APP configuration modification method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |