CN110990009A - Method for adapting different screen sizes of Android-UI and Android application development method - Google Patents
Method for adapting different screen sizes of Android-UI and Android application development method Download PDFInfo
- Publication number
- CN110990009A CN110990009A CN201911195958.XA CN201911195958A CN110990009A CN 110990009 A CN110990009 A CN 110990009A CN 201911195958 A CN201911195958 A CN 201911195958A CN 110990009 A CN110990009 A CN 110990009A
- Authority
- CN
- China
- Prior art keywords
- android
- control
- width
- height
- scaling
- 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 45
- 230000006978 adaptation Effects 0.000 claims abstract description 16
- 230000003044 adaptive effect Effects 0.000 claims abstract description 7
- 230000000694 effects Effects 0.000 abstract description 3
- 238000013467 fragmentation Methods 0.000 description 2
- 238000006062 fragmentation reaction Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/76—Adapting program code to run in a different environment; Porting
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The invention discloses an adaptation method of different screen sizes of Android-UI and an Android application development method. By the method, Android developers only need to take one specified screen size as a basis, interface UI development is carried out according to the size, the adaptive frame compares the actual screen size with the basic screen size after the customized control is loaded, automatic zooming is carried out, and the final display effect is consistent on different screen sizes.
Description
Technical Field
The invention relates to the field of Android application development, in particular to an Android-UI adaptation method for different screen sizes and an Android application development method.
Background
In the current development process, due to too serious Android fragmentation, various manufacturers perform deep customization aiming at different versions, including hardware such as screen size and density.
During Android interface development, the size of a control is basically specified in a layout xml file, then the layout file is loaded, and then an interface is rendered and displayed to a user. In order to solve the problem in the Android official network, a set of layout files is independently defined for screens with different sizes, and an Android system can automatically identify and find a proper layout file according to the name of a folder. Due to fragmentation and diversity of Android devices, more and more layout files are used for adaptation, and the adaptation workload is larger and larger.
Disclosure of Invention
The invention aims to solve the technical problem that aiming at the defects of the prior art, an adaptation method of different screen sizes of Android-UI and an Android application development method are provided, and all Android controls can be guaranteed to be adapted to screens of various sizes only by one set of UI.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows: an adaptation method for different screen sizes of Android-UI mainly comprises the following implementation processes: and after loading the Android control, acquiring the width and height of the Android control, and zooming the width and height of the Android control by taking the set screen width and height as adaptation references.
By the adaptation method, all Android controls can be guaranteed to adapt to screens of various sizes only by one set of UI.
For an aspect ratio of 16: 9, scaling the width and the height of the Android control in an equal proportion; for aspect ratios other than 16: and 9, zooming the width and the height of the Android control according to the ratio of the width to the height by taking the specified width as a zoom reference. The UI interface displayed is ensured not to be stretched or squeezed due to the fact that the size of the screen is not consistent.
In the invention, the Android control is a custom control which inherits a control of a corresponding type in an Android system control frame; for the user-defined control, duplicating an onFinishInflate () method of view in the Android system, and setting a scaling rule in the onFinishInflate () method; and defining a layout file by using the custom control, and zooming the custom control according to the layout file. The Android application adaptive to all screens is convenient to develop.
An Android application development method adaptive to all screens is characterized by comprising the following steps:
1) customizing Android native controls needing zooming;
2) duplicating any method in the Android system, and setting a scaling rule in the method; the scaling rule is as follows: acquiring the width and height of a user-defined control, and scaling the width and height of the user-defined control by taking the set width and height of a screen as adaptation references;
3) defining a layout file by using the custom control with the specified size as a standard, and defining a layout according to the given size of the control;
4) and loading the layout file into an Android application.
In the step 4), after the layout file is loaded, the actual screen size and the basic screen size are compared, and scaling is performed according to the comparison result, so that the final display effect is ensured to be consistent on different screen sizes.
Compared with the prior art, the invention has the beneficial effects that: by the method, Android developers only need to take one specified screen size as a basis, interface UI development is carried out according to the size, the adaptive frame compares the actual screen size with the basic screen size after the customized control is loaded, automatic zooming is carried out, and the final display effect is consistent on different screen sizes. According to the invention, all Android controls can be ensured to be adapted to screens of various sizes only by one set of UI, and the performance loss in the whole zooming process is very low.
Detailed Description
In the embodiment of the invention, the adaptation framework realizes the following zooming functions: and after loading the Android control, acquiring the width and height of the Android control, and zooming the width and height of the Android control by taking the set screen width and height as adaptation references.
In the present example, for an aspect ratio of 16: 9, scaling the width and the height of the Android control in an equal proportion; for aspect ratios other than 16: and 9, zooming the width and the height of the Android control according to the ratio of the width to the height by taking the specified width as a zoom reference.
The Android control in the invention is a self-defined control which inherits a control of a corresponding type in an Android system control frame; for the user-defined control, duplicating an onFinishInflate () method of view in the Android system, and setting a scaling rule in the onFinishInflate () method; and defining a layout file by using the custom control, and zooming the custom control according to the layout file. The Android application adaptive to all screens is convenient to develop. The scaling rule mentioned here refers to the scaling rule in the adaptation framework.
The embodiment also provides an Android application development method adaptive to all screens, which comprises the following steps:
1) customizing Android native controls needing zooming;
2) duplicating any method in the Android system, setting a scaling rule in the method, and scaling the actual size in an equal ratio according to the standard size according to the scaling rule; the scaling rule is as follows: acquiring the width and height of a user-defined control, and scaling the width and height of the user-defined control by taking the set width and height of a screen as adaptation references;
3) defining a layout file by using the custom control with the specified size as a standard, and defining a layout according to the given size of the control; the most common sizes in smart devices are: 1280x720, 1920x 1080. The present embodiment takes 1920 × 1080 as a specified size, i.e., a reference size. When defining the layout, the UI designer is required to design the UI using 1920x1080 as a standard, and then use the above customized control definition layout file to define the layout according to the size of the control given by the UI designer.
4) And loading the layout file into an Android application. After the system loads the layout file, a method for copying in the self-defined control is triggered, so that the Android system automatically triggers the core logic of the scaling principle of the patent.
In the implementation process, all common controls are customized, the scaling principle of the method is accessed, in the development process, a UI designer only needs to design a UI according to the size of 1920x1080, then other developers use the customized controls to develop the application according to the normal development flow, and in the process, the UI designer and the service module development engineer can develop the Android application which can be adapted to all screens without paying attention to the implementation mode of the framework layer.
Claims (8)
1. An adaptation method for different screen sizes of Android-UI is characterized by mainly comprising the following implementation processes: and after loading the Android control, acquiring the width and height of the Android control, and zooming the width and height of the Android control by taking the set screen width and height as adaptation references.
2. The method for adapting to different screen sizes of Android-UI as claimed in claim 1, wherein the aspect ratio is 16: 9, scaling the width and the height of the Android control in an equal proportion; for aspect ratios other than 16: and 9, zooming the width and the height of the Android control according to the ratio of the width to the height by taking the specified width as a zoom reference.
3. The method for adapting to different screen sizes of Android-UI as claimed in claim 1, wherein the Android control is a custom control which inherits a corresponding type of control in the Android system control framework.
4. The method for adapting different screen sizes of Android-UI as claimed in claim 3, wherein for the custom control, an onFinishInflat () method of view in Android system is duplicated, and a scaling rule is set in the onFinishInflat () method.
5. The method for adapting to different screen sizes of Android-UI as claimed in claim 4, wherein the custom control is defined by a layout file and scaled according to the layout file.
6. An Android application development method adaptive to all screens is characterized by comprising the following steps:
1) customizing Android native controls needing zooming;
2) duplicating any method in the Android system, and setting a scaling rule in the method; the scaling rule is as follows: acquiring the width and height of a user-defined control, and scaling the width and height of the user-defined control by taking the set width and height of a screen as adaptation references;
3) defining a layout file by using the custom control with the specified size as a standard, and defining a layout according to the given size of the control;
4) and loading the layout file into an Android application.
7. The Android application development method adapting to all screens of claim 6, characterized in that in step 4), after the layout file is loaded, the actual screen size and the basic screen size are compared, and scaling is performed according to the comparison result.
8. The all-screen-adapted Android application development method according to claim 6, characterized in that in step 2), for an aspect ratio of 16: 9, scaling the width and height of the custom control in equal proportion; for aspect ratios other than 16: and 9, scaling the width and the height of the custom control according to the ratio of the width to the height by taking the specified width as a scaling reference.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911195958.XA CN110990009A (en) | 2019-11-29 | 2019-11-29 | Method for adapting different screen sizes of Android-UI and Android application development method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911195958.XA CN110990009A (en) | 2019-11-29 | 2019-11-29 | Method for adapting different screen sizes of Android-UI and Android application development method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110990009A true CN110990009A (en) | 2020-04-10 |
Family
ID=70088071
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911195958.XA Pending CN110990009A (en) | 2019-11-29 | 2019-11-29 | Method for adapting different screen sizes of Android-UI and Android application development method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110990009A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112817507A (en) * | 2021-01-26 | 2021-05-18 | 广州虎牙科技有限公司 | Control adaptation method and device, electronic equipment and storage medium |
CN113961158A (en) * | 2021-09-08 | 2022-01-21 | 北京房江湖科技有限公司 | Cross-platform painting brush synchronization method and device |
CN115033335A (en) * | 2022-08-11 | 2022-09-09 | 青岛中正合力软件有限公司 | Display processing method applied to same screen of webpage |
EP4209898A4 (en) * | 2020-09-29 | 2024-03-13 | Huawei Technologies Co., Ltd. | Application interface layout method and electronic device |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102622217A (en) * | 2011-01-30 | 2012-08-01 | 中兴通讯股份有限公司 | Cross-screen operation application method and system |
CN105282321A (en) * | 2015-08-28 | 2016-01-27 | 上海健保科技有限公司 | Adaption method of application software user interface and display device |
CN105511725A (en) * | 2015-12-09 | 2016-04-20 | 网易(杭州)网络有限公司 | Method and device for displaying controls in interface |
CN106406794A (en) * | 2016-09-14 | 2017-02-15 | 乐视控股(北京)有限公司 | Screen adapting method and device |
CN106484424A (en) * | 2016-10-18 | 2017-03-08 | 武汉斗鱼网络科技有限公司 | A kind of method and system obtaining the control being adapted to screen |
CN108419114A (en) * | 2018-01-18 | 2018-08-17 | 海尔优家智能科技(北京)有限公司 | A kind of UI interface display methods, device and storage medium for smart television |
CN110083415A (en) * | 2019-03-25 | 2019-08-02 | 厦门网宿有限公司 | Device screen adaptation method, terminal device and storage medium |
-
2019
- 2019-11-29 CN CN201911195958.XA patent/CN110990009A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102622217A (en) * | 2011-01-30 | 2012-08-01 | 中兴通讯股份有限公司 | Cross-screen operation application method and system |
CN105282321A (en) * | 2015-08-28 | 2016-01-27 | 上海健保科技有限公司 | Adaption method of application software user interface and display device |
CN105511725A (en) * | 2015-12-09 | 2016-04-20 | 网易(杭州)网络有限公司 | Method and device for displaying controls in interface |
CN106406794A (en) * | 2016-09-14 | 2017-02-15 | 乐视控股(北京)有限公司 | Screen adapting method and device |
CN106484424A (en) * | 2016-10-18 | 2017-03-08 | 武汉斗鱼网络科技有限公司 | A kind of method and system obtaining the control being adapted to screen |
CN108419114A (en) * | 2018-01-18 | 2018-08-17 | 海尔优家智能科技(北京)有限公司 | A kind of UI interface display methods, device and storage medium for smart television |
CN110083415A (en) * | 2019-03-25 | 2019-08-02 | 厦门网宿有限公司 | Device screen adaptation method, terminal device and storage medium |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP4209898A4 (en) * | 2020-09-29 | 2024-03-13 | Huawei Technologies Co., Ltd. | Application interface layout method and electronic device |
CN112817507A (en) * | 2021-01-26 | 2021-05-18 | 广州虎牙科技有限公司 | Control adaptation method and device, electronic equipment and storage medium |
CN112817507B (en) * | 2021-01-26 | 2023-11-03 | 广州虎牙科技有限公司 | Control adaptation method, device, electronic equipment and storage medium |
CN113961158A (en) * | 2021-09-08 | 2022-01-21 | 北京房江湖科技有限公司 | Cross-platform painting brush synchronization method and device |
CN115033335A (en) * | 2022-08-11 | 2022-09-09 | 青岛中正合力软件有限公司 | Display processing method applied to same screen of webpage |
CN115033335B (en) * | 2022-08-11 | 2023-01-10 | 青岛中正合力软件有限公司 | Display processing method applied to same screen of webpage |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110990009A (en) | Method for adapting different screen sizes of Android-UI and Android application development method | |
US10929109B2 (en) | Method and apparatus for converting building block programming into program code | |
CN106339226B (en) | A kind of methods of exhibiting and page presentation device of Webpage | |
WO2020048326A1 (en) | Interface display method and system, and terminal device | |
CN110764850A (en) | Interface display method, parameter assignment method, system and equipment | |
CN107733985B (en) | Method and device for deploying functional components of cloud computing system | |
CN107656914A (en) | Form generation method, device, terminal device and the storage medium of configurableization | |
CN108965471B (en) | Method for improving browser memory on smart television | |
CN104199691B (en) | A kind of method and terminal of the start self-starting APK based on Android platform | |
CN104267996A (en) | Image resource processing method, device and terminal | |
CN102789357A (en) | Method and device for setting subject resources based on Andriod application technology | |
CN107402871B (en) | Terminal performance monitoring method and device and monitoring file processing method and device | |
CN107562483A (en) | A kind of method and device of carry guiding file system | |
CN107066377B (en) | Page element obtaining method based on Android system and terminal equipment | |
CN103914314A (en) | Method and device for adjusting brightness of display screen | |
CN104615396A (en) | Android-based resolution ratio automatic adjustment method and system | |
US20180046472A1 (en) | Method and system for customizing desktop launcher of mobile terminal | |
CN109101233A (en) | It is adapted to the method, storage equipment and Android device of a variety of screen resolutions | |
CN104793945A (en) | Large-batch picture displaying method for preventing memory overflow and device thereof | |
CN106095519A (en) | A kind of Ambari of use extends the method for self-defined service in big data package manages | |
CN108632533A (en) | A kind of control method of camera, mobile terminal and computer readable storage medium | |
CN108519894B (en) | Music box loading initialization method | |
CN107092413A (en) | A kind of visible controls corners processing method and system | |
CN105373373B (en) | Method and device for quickly generating icon | |
CN109067562A (en) | Dynamic configuration update method and system, server and medium based on intelligent pointer |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200410 |
|
RJ01 | Rejection of invention patent application after publication |