CN105827833A - Percentage-based Android mobile phone screen adaption method - Google Patents

Percentage-based Android mobile phone screen adaption method Download PDF

Info

Publication number
CN105827833A
CN105827833A CN201610164574.1A CN201610164574A CN105827833A CN 105827833 A CN105827833 A CN 105827833A CN 201610164574 A CN201610164574 A CN 201610164574A CN 105827833 A CN105827833 A CN 105827833A
Authority
CN
China
Prior art keywords
resolution
adaptive
file
mobile phone
screen
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
Application number
CN201610164574.1A
Other languages
Chinese (zh)
Inventor
钱程
蒋国平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Post and Telecommunication University
Nanjing University of Posts and Telecommunications
Original Assignee
Nanjing Post and Telecommunication University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Nanjing Post and Telecommunication University filed Critical Nanjing Post and Telecommunication University
Priority to CN201610164574.1A priority Critical patent/CN105827833A/en
Publication of CN105827833A publication Critical patent/CN105827833A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • H04M1/72427User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality for supporting games or graphical animations

Landscapes

  • Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Stored Programmes (AREA)
  • Telephone Function (AREA)

Abstract

The present invention discloses a percentage-based Android mobile phone screen adaption method. Aiming at the insufficiency of a conventional Android mobile phone screen adaption scheme, the method provides a percentage-based screen adaption scheme according to a mapping relationship between the screen size and the pixel independent density, and the scheme mainly comprises determining the mobile phone screen resolution needing to be adapted, equally dividing the mobile phone screen resolution needing to be adapted in a transverse direction and a longitudinal direction according to a UI reference, calculating the pixel values corresponding to the height and the width of a unit respectively under the reference, and then programming to generate a utility class of an adaption file automatically, generating an XML file corresponding to the resolution needing to be adapted, and setting the parameters of a control in a manner of citing the corresponding numerical values in the adaption file, so that a system can find out the accurate pixel values to set the control according to the resolution of a current device, and the accurate adaption can be realized. The percentage-based Android mobile phone screen adaption method of the present invention utilizes an adaptive characteristic of an Android system, and by being compared with a conventional adaption scheme, enables different mobile phone resolutions to be adapted accurately.

Description

A kind of Android cellphone screen adaptation method based on percentage ratio
Technical field
The present invention relates to the image conversion techniques in a kind of image real time transfer field, be specifically related to a kind of screen adaptation method for android system mobile terminal.
Background technology
Along with developing rapidly of the Internet, the exploitation of mobile client application has been pulled to the teeth of the storm.According to report display in Chinese market the market share of android system 2014 oneself through increasing to 86%, and also constantly promoting.At home on market, as the MIUI of Semen setariae, the EMUI of Huawei, the Flyme system etc. of Meizu, it is all the operating system of degree of depth customization on the basis of android system, meets the use habit of compatriots with this.But just because of this opening so that the customization of android system is uneven.Different vendor can need custom-built system according to self, therefore occurs in that " fragmentation " problem.As shown in Figure 1.In this figure, each rectangle represents a kind of Android device screen size.
Traditional adaptive solution is, uses wrap_content, match_parent, weight attribute to set width and the height of a control when writing topology file as far as possible.Use wrap_content, system will be by the width of view or be highly arranged to required minimum dimension with the content adapting in view, and match_parent (being referred to as fill_parent in the rank less than api class other 8) the most unfolded assembly is to fill the size of his father's view.And the particular attribute in weight Ze Shi linear placement (LinerLayout), interface can be allocated by we according to this ratio of longitudinal or horizontal control number and weight.But if it is intended to interface becomes more attractive in appearance, more conforms to the use habit of user, it is far from being enough simply by virtue of this method.So we have suggested unrelated density unit dp and sp of pixel to control the length and width of control.Although dp can make the effect approximation that identical control shows under different screens, but not all screen width is all identical dp length.When the physical size of equipment there are differences when, dp just seems helpless.It is such as the UI of 4.3 cun of screens preparations, operates on the screen of 5.0 cun, it is likely that there is substantial amounts of blank on right side and downside;And the UI of 5.0 cun runs on the equipment of 4.3 cun, just cannot all show.So above-mentioned conventional adaptation solution can not solve all adaptation issues, although dp can allow same numerical value show roughly the same size at different resolution, such as, the problem that the invention of Publication No. CN103905643A needs to use the background picture of different resolution for the mobile phone screen of different resolution, propose a kind of uniform background picture cell phones adaptation method, but when the size difference of equipment is bigger, this method is the most helpless.
The screen adaptation of Android phone be the most all developer have to faced by the problem of a headache.From mobile phone to flat board, the most various mobile device screen sizes and resolution are of all kinds now, Android developer also needs to uneven equipment and customization system are completed adaptation while the function of application, to improve Consumer's Experience, this needs to disperse sizable time and efforts.So it is imperative to propose one the most reusable screen adaptation scheme.
Summary of the invention
The present invention is directed to the deficiency of above-mentioned existing Android cellphone screen adaptation scheme, it is proposed that a kind of screen adaptation scheme based on percentage ratio according to the mapping relations between screen size and pixel unrelated density (DensityIndependentPixels).
The present invention is between the unrelated density of screen size and pixel on the basis of mapping relations, propose a kind of mobile phone screen adaptation method based on percentage ratio, convenient can complete the work of screen adaptation accurately, make developer can be designed that user interface that is more rich and varied and that have preferable interactive experience.Comprise the following steps:
(1) determine, according to project demands, the mobile phone screen resolution that needs are adaptive, including resolution and the special resolution (such as flat board etc.) of main flow on the market.
(2) on the basis of the resolution of the design drawing be given by UI, it would be desirable to adaptive mobile phone screen resolution carries out decile with this benchmark on horizontal and vertical, and calculate the height at this benchmark next one unit and distinguished corresponding pixel value with width.
(3) then by the programming of file iostream, realize automatically generating the tool-class of adaptation file, generate and need the adaptive values file corresponding to resolution, with the form of " values-needs adaptive resolution ", this document folder is named, two files are comprised under this document folder, being record screen width pixel value and the XML file of screen height pixel value respectively, these pixel values are from the result of calculation in step 2.
(4) when writing topology file, directly use the px numerical value in design drawing, i.e. by quoting attribute and the distance arranging control in adaptation file by the way of corresponding numerical value, system can find pixel value accurately to arrange to control according in the values file generated in the resolution of current device to step 3, such that it is able to realize adaptive accurately.
If needing more adaptive special resolution, then adaptive special resolution will be needed to input with the form of parameter by the way of order line, generate the adaptation file needing adaptive resolution, then according to the adaptive characteristic of android system, these adaptation file folder is added under the res catalogue of Android project, finally perform step 4, complete adaptive accurately.
Beneficial effect: the present invention is according to the deficiency of screen adaptation scheme in current Android project development process, it is proposed that a kind of screen adaptation scheme based on percentage ratio according to the mapping relations between screen size and pixel unrelated density (DensityIndependentPixels).The program has the advantage that
(1) according to android system adaptive characteristic, the pixel value of correspondence it is calculated under different resolution, so can the most adaptive different mobile phone resolution compared with conventional adaptation scheme.
(2) program is on the basis of the design drawing resolution that UI is given, and can directly use the px numerical value of mark in design drawing to arrange wide high attribute with developer, the most convenient, alleviates the pressure that developer changes between px and dp.
(3) and resolution is to carry out decile with benchmark, it is easy to realize the percentage ratio layout being similar in WEB page layout, this attribute not having in Android layout just.
(4) program generate each resolution be adaptation file be general, disparity items can use identical adaptation file, so having good durability.
(5) if desired add new adaptive resolution and have only to by the way of order line, it is possible to quickly generate the adaptation file of the resolution of correspondence, there is good autgmentability.
Accompanying drawing explanation
Fig. 1 is the schematic diagram reflecting current Android device screen " fragmentation " problem.
Fig. 2 is the flow chart of adaptation scheme of the present invention.
Fig. 3 is the adaptive flow chart of one embodiment of the invention.
Detailed description of the invention
It is embodied as being further described to the present invention in conjunction with accompanying drawing.
The present invention is between the unrelated density of screen size and pixel on the basis of mapping relations, propose a kind of mobile phone screen adaptation method based on percentage ratio, convenient can complete the work of screen adaptation accurately, make developer can be designed that user interface that is more rich and varied and that have preferable interactive experience.As in figure 2 it is shown, comprise the following steps:
(1) determine, according to project demands, the mobile phone screen resolution that needs are adaptive, including resolution and the special resolution (such as flat board etc.) of main flow on the market.
(2) on the basis of the resolution of the design drawing be given by UI, it would be desirable to adaptive mobile phone screen resolution carries out decile with this benchmark on horizontal and vertical, and calculate the height at this benchmark next one unit and distinguished corresponding pixel value with width.
(3) then by the programming of file iostream, realize automatically generating the tool-class of adaptation file, generate and need the adaptive values file corresponding to resolution, with the form of " values-needs adaptive resolution ", this document folder is named, two files are comprised under this document folder, being record screen width pixel value and the XML file of screen height pixel value respectively, these pixel values are from the result of calculation in step 2.
(4) when writing topology file, directly use the px numerical value in design drawing, i.e. by quoting attribute and the distance arranging control in adaptation file by the way of corresponding numerical value, system can find pixel value accurately to arrange to control according in the values file generated in the resolution of current device to step 3, such that it is able to realize adaptive accurately.
If needing more adaptive special resolution, then adaptive special resolution will be needed to input with the form of parameter by the way of order line, generate the adaptation file needing adaptive resolution, then according to the adaptive characteristic of android system, these adaptation file folder is added under the res catalogue of Android project, finally perform step 4, complete adaptive accurately.
Present invention also offers an embodiment, the flow chart of steps that its adaptive case is implemented is as shown in Figure 3.When using the program to carry out the screen adaptation of Android device, it is necessary first to determine according to project demands and need adaptive resolution, including the mobile phone screen resolution of main flow on market and need some adaptive special resolution.Then reference resolution is elected as with the resolution of the design sketch of UI design.General UI its resolution when design effect figure is fixed, on the basis of being, such as design drawing, the resolution then choosing 480*320 designed according to the resolution of 480*320;Write JAVA tool-class and realize automatically generating of adaptation file.The file automatically generated comprises main flow resolution, and if desired other resolution adaptive can be realized by the form of order line;Finally again the adaptation file of generation is joined in project, quote during layout and can complete adaptive work.
Now above step is elaborated:
Step 1: when adaptation, it is thus necessary to determine that need adaptive resolution.In addition to the resolution that adaptation compares main flow on the market, also need to need more adaptive more special resolution according to project, such as some application need simultaneously towards mobile phone terminal user and tablet device user, then the resolution of some tablet device also needs to take into account.Device resolution present on concrete market can be inquired about by following network address:http://screensiz.es/phone
Step 2: need to confirm a reference resolution, and calculate under different resolution the pixel p x value shared by width every part x1 and highly every part y1 with this.Typically in a project development process, UI can provide the design effect figure at each interface, and Android developer needs to write the layout at interface according to this design sketch.These interfacial effect figures are typically all based on same resolution.The design sketch that such as UI is given is based on 320*480 resolution, then on the basis of this resolution, the width of any resolution can be divided into 320 parts, value is x1-x320;The height of any resolution is divided into 480 parts, and value is y1-y480.Then the pixel count shared by x1 and y1 under arbitrary resolution is calculated.The screen of such as adaptive 320*480 resolution, owing to this resolution is identical with benchmark, then corresponding x1=1px, y1=1px.If desired the screen of adaptive 1080*1920, then according to x1=1080/ benchmark=1080/320=3.37px, y1=1920/ benchmark=1920/480=4px.Calculate x1-x320 and y1-y480 the most respectively.Additionally in design drawing, the wide high and distance of control is all marked by px unit, so x [1-320] can directly px be converted into, y [1-480], so can directly use the size in design drawing just can complete the adaptation of full resolution when writing layout.A moderate dp value need not be calculated according to the px of design drawing the most as before and arrange wide high again, and this method display effect under different screen size and resolution is also discrepant, affects Consumer's Experience.
Step 3: by above-mentioned introduction, it would be desirable to generate an adaptation file folder for each of adaptation resolution.The naming rule of file is valuse+ adaptation resolution.The such as folder name for adaptive 1920*1080 resolution is referred to as values-1920x1080.Comprising two XML file under this document folder, comprise the px value corresponding to x1-x320 and lay_y.xml file inside respectively lay_x.xml, the inside comprises the px value corresponding to y1-y480.Owing to needing adaptive resolution ratio more, it would be desirable to write a tool-class by the file iostream of JAVA and automatically generate these files.This tool-class needs to generate the adaptation file of main flow resolution.And in view of extensibility, need in main method to receive args parameter, so user can be by the way of order line when needing and some special resolution being done adaptation: java-jarxx.jarwidthheight generates by the adaptation file of resolution, completes the adaptation to special resolution with this.
, if there is or the resolution sizes of approximation identical with the mobile phone running current application in the resource folder suffix of an Android application, then system can preferentially use the resource file under this resource folder in step 4: according to the characteristic of android system.So needing, under the res catalogue that these files join project, to facilitate system to quote according to different situations after generating adaptation file.
Step 5: last when writing topology file, arranges the wide high and distance of control by the way of using dimen/x numerical value.If the interface of UI design is based on 320*480, and mark a length of 160px of a control, then have only to length width of this control is set to dimen/x160.The machine of 320*480 can use the value of the x160 under respective file be 160px be the half of width, and can use value 540px of the x160 under values-1920x1080 also for the half of screen width on the machine of 1920*1080, other resolution are by that analogy.As long as to sum up the simple px numerical value using design drawing mark can complete the adaptation of all resolution device.
The foregoing is only a specific embodiment of the present invention, not in order to limit the present invention, all within the spirit and principles in the present invention, any modification, equivalent substitution and improvement etc. made, should be included within the scope of the present invention.

Claims (2)

1. an Android cellphone screen adaptation method based on percentage ratio, it is characterised in that comprise the following steps:
1) determine, according to project demands, the mobile phone screen resolution that needs are adaptive;
2) on the basis of the resolution of the design drawing be given by UI, it would be desirable to adaptive mobile phone screen resolution carries out decile with this benchmark on horizontal and vertical, and calculate the height at this benchmark next one unit and distinguished corresponding pixel value px with width;
3) by the programming of file iostream, realize automatically generating the tool-class of adaptation file, generate and need the adaptive values file corresponding to resolution, with the form of " values-needs adaptive resolution ", this document folder is named, two files are comprised under this document folder, being record screen width pixel value and the XML file of screen height pixel value respectively, these pixel values are from the result of calculation in step 2;
4) the px numerical value in design drawing is directly used when writing topology file, i.e. by quoting attribute and the distance arranging control in adaptation file by the way of corresponding numerical value, system can find pixel value accurately to arrange to control according in the values file generated in the resolution of current device to above-mentioned steps 3, such that it is able to realize adaptive accurately.
A kind of Android cellphone screen adaptation method based on percentage ratio the most according to claim 1, it is characterized in that if needing more adaptive special resolution, then adaptive special resolution will be needed to input with the form of parameter by the way of order line, generate the adaptation file needing adaptive resolution, then according to the adaptive characteristic of android system, these adaptation file folder is added under the res catalogue of Android project, finally perform step 4, complete adaptive accurately.
CN201610164574.1A 2016-03-22 2016-03-22 Percentage-based Android mobile phone screen adaption method Pending CN105827833A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610164574.1A CN105827833A (en) 2016-03-22 2016-03-22 Percentage-based Android mobile phone screen adaption method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610164574.1A CN105827833A (en) 2016-03-22 2016-03-22 Percentage-based Android mobile phone screen adaption method

Publications (1)

Publication Number Publication Date
CN105827833A true CN105827833A (en) 2016-08-03

Family

ID=56524941

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610164574.1A Pending CN105827833A (en) 2016-03-22 2016-03-22 Percentage-based Android mobile phone screen adaption method

Country Status (1)

Country Link
CN (1) CN105827833A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107092479A (en) * 2017-03-17 2017-08-25 武汉斗鱼网络科技有限公司 Screen adaptation method and system for Android widescreen equipment
CN107980121A (en) * 2017-03-20 2018-05-01 深圳大趋智能科技有限公司 Circular self-defined control performs the method and device of animation
CN108415754A (en) * 2018-03-15 2018-08-17 万帮充电设备有限公司 Android UI adaptation methods and device
CN108984253A (en) * 2018-06-29 2018-12-11 奇酷互联网络科技(深圳)有限公司 Application Program Interface display methods, device, readable storage medium storing program for executing and mobile terminal
CN111338733A (en) * 2020-02-25 2020-06-26 珠海格力电器股份有限公司 User interface adaptation method and system
CN111708502A (en) * 2020-05-20 2020-09-25 北京明略软件系统有限公司 Screen adaptation method and device
CN111986601A (en) * 2020-07-13 2020-11-24 视联动力信息技术股份有限公司 Screen display method and device, terminal equipment and storage medium
CN112130840A (en) * 2020-07-31 2020-12-25 北京编程猫科技有限公司 Intelligent programming implementation method and device for obtaining type of operating equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015226220A (en) * 2014-05-28 2015-12-14 京セラ株式会社 Mobile terminal and screen output method
CN105282321A (en) * 2015-08-28 2016-01-27 上海健保科技有限公司 Adaption method of application software user interface and display device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015226220A (en) * 2014-05-28 2015-12-14 京セラ株式会社 Mobile terminal and screen output method
CN105282321A (en) * 2015-08-28 2016-01-27 上海健保科技有限公司 Adaption method of application software user interface and display device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵凯强的博客: "Android屏幕适配全攻略(最权威的官方适配指导)", 《COCOA CHINA》 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107092479A (en) * 2017-03-17 2017-08-25 武汉斗鱼网络科技有限公司 Screen adaptation method and system for Android widescreen equipment
CN107980121A (en) * 2017-03-20 2018-05-01 深圳大趋智能科技有限公司 Circular self-defined control performs the method and device of animation
CN108415754A (en) * 2018-03-15 2018-08-17 万帮充电设备有限公司 Android UI adaptation methods and device
CN108984253A (en) * 2018-06-29 2018-12-11 奇酷互联网络科技(深圳)有限公司 Application Program Interface display methods, device, readable storage medium storing program for executing and mobile terminal
CN111338733A (en) * 2020-02-25 2020-06-26 珠海格力电器股份有限公司 User interface adaptation method and system
CN111708502A (en) * 2020-05-20 2020-09-25 北京明略软件系统有限公司 Screen adaptation method and device
CN111708502B (en) * 2020-05-20 2023-05-16 北京明略软件系统有限公司 Screen adaptation method and device
CN111986601A (en) * 2020-07-13 2020-11-24 视联动力信息技术股份有限公司 Screen display method and device, terminal equipment and storage medium
CN111986601B (en) * 2020-07-13 2024-03-29 视联动力信息技术股份有限公司 Screen display method, device, terminal equipment and storage medium
CN112130840A (en) * 2020-07-31 2020-12-25 北京编程猫科技有限公司 Intelligent programming implementation method and device for obtaining type of operating equipment

Similar Documents

Publication Publication Date Title
CN105827833A (en) Percentage-based Android mobile phone screen adaption method
KR20120045586A (en) Apparatus and method for setting saas(software as a service) applications for multi-tenant
CN104484189A (en) Construction and design method of application interface
CN104750372B (en) A kind of file sharing method and device
CN103955367A (en) Method and device for generating pages
US10999411B2 (en) User interface and content translation system
CN106055716A (en) Method and equipment for automatically generating website
CN103645908A (en) Full life circle development achievement system of intemetware
CN102298495A (en) Method for enabling android software to adapt to different screen densities
CN110708235A (en) Message generation method and device, storage medium and computer equipment
CN106331749B (en) Video request method and system
CN106294299A (en) A kind of report form generation method and device
CN109583616A (en) A kind of information recommendation method and device and storage medium
CN105094574A (en) Method and device for updating configuration of navigation menu
CN109683957A (en) The method and apparatus of Function Extension
CN114281463B (en) Form interface format configuration and interface display method, device and medium
CN101155174B (en) Remote subscriber interface service implementing method based on common protocol
CN104902432A (en) Method and device for generating application operation log of terminal mobile
CN103473105A (en) Realizing method of online code completion function
CN105262790A (en) File transmission method for mobile terminal
CN105677699A (en) Method and apparatus for generating news pages for user
CN108717368A (en) Sending method, interface of mobile terminal composition method and the device of interface typesetting pattern
CN105824790A (en) Equipment table adapting method, computer equipment and mobile terminal
CN102868910B (en) Cloud platform based video-on-demand system and video-on-demand expanding control method
CN104111768A (en) Interactive window, methods and systems for defining, quoting and synchronizing interactive windows

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160803