CN110007919A - A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane - Google Patents
A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane Download PDFInfo
- Publication number
- CN110007919A CN110007919A CN201910275990.2A CN201910275990A CN110007919A CN 110007919 A CN110007919 A CN 110007919A CN 201910275990 A CN201910275990 A CN 201910275990A CN 110007919 A CN110007919 A CN 110007919A
- Authority
- CN
- China
- Prior art keywords
- density
- screen
- android
- dynamic
- dpi
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
Description
技术领域technical field
本发明涉及应用界面图像处理技术领域,更具体地,涉及一种用于无人机自动机场的动态密度屏幕适配方法及系统。The invention relates to the technical field of application interface image processing, and more particularly, to a dynamic density screen adaptation method and system for an unmanned aerial vehicle automatic airport.
背景技术Background technique
近年来,无人机(Unmanned Aerial Vehicle,UAV)由于其具有成本低,飞行精度高,机动灵活,使用操作便利等优点,在各个行业和领域都得到了广泛应用,如地质勘探、物流运输、电力巡检、农业植保等。In recent years, Unmanned Aerial Vehicle (UAV) has been widely used in various industries and fields due to its advantages of low cost, high flight accuracy, flexible maneuverability, and convenient use and operation, such as geological exploration, logistics transportation, Electric power inspection, agricultural plant protection, etc.
在电力巡检领域,无人机巡检已经成为常态,而基于无人机和智能终端设备的自动化智能巡检系统也得到了越来越多的重视和使用,自动化智能巡检系统也形象地被称为自动机场,能大幅度提升电力巡检的效率,降低人力成本,消除人员安全风险,其中智能终端设备位于机场内,用于控制无人机起飞、巡检飞行、降落等一系列动作,是自动机场的核心。为了满足不同场景的需要,无人机自动机场存在不同形状尺寸、不同额定功率等各种型号,所以内部的Android智能终端设备也采用了不同的型号,因此如何开发一套应用界面来适配不同分辨率、不同尺寸的Android智能终端屏幕,避免重复开发,显得尤为重要。In the field of electric power inspection, drone inspection has become the norm, and the automated intelligent inspection system based on UAV and intelligent terminal equipment has also received more and more attention and use, and the automated intelligent inspection system has also vividly Known as an automatic airport, it can greatly improve the efficiency of power inspection, reduce labor costs, and eliminate personnel safety risks. The intelligent terminal equipment is located in the airport and is used to control a series of actions such as take-off, inspection flight, and landing of drones. , is the core of the automatic airport. In order to meet the needs of different scenarios, there are various models of drone automatic airports with different shapes and sizes, different rated powers, etc., so the internal Android smart terminal devices also use different models, so how to develop a set of application interfaces to adapt to different It is particularly important to avoid repeated development of Android smart terminal screens with different resolutions and sizes.
由于无人机固定机场的使用经常需要更换不同分辨率和尺寸的Android智能终端,这对于Android应用开发者来说,面对屏幕碎片化如此多样的Android智能终端,怎么开发一套应用界面就可以适配不同分辨率不同尺寸大小的Android智能终端屏幕的显示,来应付无人机固定机场场景下碎片化的Android设备,就变得尤为重要。Since the use of drones in fixed airports often requires the replacement of Android smart terminals with different resolutions and sizes, for Android application developers, in the face of such a variety of Android smart terminals with fragmented screens, how can they develop an application interface? It is particularly important to adapt to the display of Android smart terminal screens of different resolutions and sizes to cope with the fragmented Android devices in the drone fixed airport scene.
应用界面的开发是Android应用开发的重要组成部分,其开发成本甚至比应用功能开发的成本还要大。应用界面是直接与用户打交道的部分,好的用户体验可以让应用产品受到用户的青睐。如果开发者一开始并没有注意到应用界面的适配问题,等到开发完成后,发现应用界面在不同尺寸分辨率的手机上所呈现的视觉效果差别很大,那将是很头疼的事情。The development of application interface is an important part of Android application development, and its development cost is even greater than the cost of application function development. The application interface is the part that deals directly with users, and a good user experience can make application products favored by users. If the developer does not notice the adaptation of the application interface at the beginning, after the development is completed, it will be a headache to find that the visual effect of the application interface on mobile phones of different sizes and resolutions is very different.
从Android5.0开始,谷歌Android官方推出了百分比布局支持库,意在解决大部分屏幕适配的问题。使用百分比布局作为应用界面的根布局,子控件的宽高不再设置为具体的长度值,而是设置为一个百分比值。由于根布局是填满整个屏幕的,而子控件的宽高是屏幕宽高的百分比值,这样一来,无论屏幕的分辨率大小是多少,子控件都会按照屏幕宽高的百分比进行显示,从比例这个维度来看,其视觉效果上是接近的,从而实现了屏幕的适配。Starting from Android 5.0, Google Android officially launched the percentage layout support library, which is intended to solve most of the screen adaptation problems. Using the percentage layout as the root layout of the application interface, the width and height of the child controls are no longer set to a specific length value, but set to a percentage value. Since the root layout fills the entire screen, and the width and height of the child controls are a percentage of the screen width and height, no matter what the resolution of the screen is, the child controls will be displayed according to the percentage of the screen width and height, starting from From the perspective of scale, the visual effect is close, thus realizing the adaptation of the screen.
谷歌Android官方百分比布局方案实现的原理很简单,就是按比例显示。通过比例值,计算出各个UI控件真实的宽高,然后再渲染到屏幕上。如图1所示,是在屏幕宽高不同的手机上显示的百分比布局效果。The principle of Google Android's official percentage layout scheme is very simple, that is, it is displayed in proportion. Through the ratio value, the real width and height of each UI control are calculated, and then rendered to the screen. As shown in Figure 1, it is the percentage layout effect displayed on mobile phones with different screen widths and heights.
该方案的具体使用方法如下:The specific use of the program is as follows:
1、在Android代码项目的配置文件中添加如下配置:1. Add the following configuration to the configuration file of the Android code project:
compile‘com.android.surpport:percent:25.3.0’compile'com.android.surpport:percent:25.3.0'
2、xml布局文件中引入百分比布局,并以百分比值作为UI子控件的宽高,如下示例:2. The percentage layout is introduced into the xml layout file, and the percentage value is used as the width and height of the UI sub-control, as shown in the following example:
仅需遵循以上的使用方式,则可以做到屏幕的适配。Just follow the above usage methods, you can achieve screen adaptation.
对于已经开发完成的且没有做屏幕适配的应用产品来说,如果使用该方案进行屏幕适配,需要将所有的xml布局文件中的根布局以百分比布局进行替换,同时,需要将所有的xml布局文件中涉及到的宽高以百分比的方式进行修改替换。如果xml布局文件数目非常多,那么使用该方案修改起来将会引入很大的时间成本和人力成本,而这种成本往往可能是消耗不起的。对于已经开发完成的且没有做屏幕适配的应用产品来说,如果使用该方案进行屏幕适配,代码的侵入性非常高,违反了代码设计中“高内聚,低耦合”的原则,而且过多的代码侵入,可能会引入新的问题,造成软件运行的不稳定。For applications that have been developed without screen adaptation, if you use this solution for screen adaptation, you need to replace the root layout in all xml layout files with percentage layouts, and at the same time, you need to replace all xml The width and height involved in the layout file are modified and replaced by percentage. If the number of xml layout files is very large, then using this scheme to modify will introduce a lot of time and labor costs, and this cost may often be unaffordable. For application products that have been developed without screen adaptation, if this solution is used for screen adaptation, the code is very intrusive, violating the principle of "high cohesion, low coupling" in code design, and Excessive code intrusion may introduce new problems and cause unstable software operation.
使用该方案进行屏幕适配是比较消耗性能的,因为Android系统在渲染界面时要根据百分比值算出各个UI控件的真实宽高,这个计算成本是比较高的,特别是渲染的UI控件数量很多的情况下。Using this solution for screen adaptation consumes more performance, because the Android system needs to calculate the real width and height of each UI control according to the percentage value when rendering the interface. This calculation cost is relatively high, especially the number of rendered UI controls is large. case.
因此,急需一种低成本、简单快速且优雅的方法来解决这个问题,满足不同尺寸、分辨率下的Android智能终端屏幕显示的需要,避免同时维护和修改多套应用界面而增加开发成本,因为一个软件项目的后期维护迭代成本远高于前期的开发成本,所以这对于Android应用界面适配开发工作将具有重大的应用价值。Therefore, there is an urgent need for a low-cost, simple, fast and elegant method to solve this problem, to meet the needs of Android smart terminal screen display under different sizes and resolutions, and to avoid maintaining and modifying multiple sets of application interfaces at the same time and increasing development costs, because The later maintenance and iteration cost of a software project is much higher than the early development cost, so this will have great application value for the development of Android application interface adaptation.
发明内容SUMMARY OF THE INVENTION
本发明要解决的技术问题在于,针对现有技术的上述缺陷,提供一种用于无人机自动机场的动态密度屏幕适配方法及系统。The technical problem to be solved by the present invention is to provide a dynamic density screen adaptation method and system for an unmanned aerial vehicle automatic airport in view of the above-mentioned defects of the prior art.
本发明解决其技术问题所采用的技术方案是:根据本发明的第一方面,提供一种用于无人机自动机场的动态密度屏幕适配方法,具体包括步骤:The technical solution adopted by the present invention to solve the technical problem is: according to the first aspect of the present invention, a dynamic density screen adaptation method for an unmanned aerial vehicle automatic airport is provided, which specifically includes the steps:
S10、获取设计图纸的横向虚拟像素值dp;S10. Obtain the horizontal virtual pixel value dp of the design drawing;
S20、动态获取屏幕分辨率的横向像素值px;S20. Dynamically obtain the horizontal pixel value px of the screen resolution;
S30、计算新的安卓密度系数density和屏幕像素密度dpi;S30, calculate the new Android density coefficient density and screen pixel density dpi;
S40、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi。S40, replace the old Android density factor density and screen pixel density dpi with the new Android density factor density and screen pixel density dpi.
优选的,所述S40、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi,具体包括步骤:Preferably, the S40, using the new Android density coefficient density and screen pixel density dpi to replace the old Android density coefficient density and screen pixel density dpi, specifically includes the steps:
S410、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi;S410, use the new Android density coefficient density and screen pixel density dpi to replace the old Android density coefficient density and screen pixel density dpi;
S420、更新Android系统的Display Metrics对象;S420. Update the Display Metrics object of the Android system;
S430、对UI界面布局进行渲染。S430. Render the UI interface layout.
优选的,S10、设计图纸的横向虚拟像素值dp从所述设计图纸的标注说明获得。Preferably, in S10, the horizontal virtual pixel value dp of the design drawing is obtained from the annotation description of the design drawing.
优选的,所述S20、动态获取屏幕分辨率的横向像素值px,具体包括步骤:Preferably, the S20, dynamically obtaining the horizontal pixel value px of the screen resolution, specifically includes the steps:
通过Android系统的Display Metrics对象中动态获取屏幕分辨率的横向像素值px。The horizontal pixel value px of the screen resolution is dynamically obtained from the Display Metrics object of the Android system.
优选的,所述S30、计算新的安卓密度系数density和屏幕像素密度dpi,计算公式为:Preferably, the S30, calculating the new Android density coefficient density and screen pixel density dpi, the calculation formula is:
dpi=160*density。dpi=160*density.
本发明还提供一种计算机可读的存储介质,所述存储介质上存储有计算机程序,所述计算机程序被执行时实现上文所述的用于无人机自动机场的动态密度屏幕适配方法。The present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed, realizes the above-mentioned dynamic density screen adaptation method for an unmanned aerial vehicle airport .
本发明还提供一种用于无人机自动机场的动态密度屏幕适配装置,包括处理器及存储器;其中,所述存储器用于存储计算机程序,所述处理器用于执行存储器存储的计算机程序,以使处理器执行如上文所述的用于无人机自动机场的动态密度屏幕适配方法。The present invention also provides a dynamic density screen adaptation device for an unmanned aerial vehicle airport, comprising a processor and a memory; wherein, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, to cause the processor to perform the dynamic density screen adaptation method for the drone autodrome as described above.
本发明还提供一种用于无人机自动机场的动态密度屏幕适配系统,所述动态密度屏幕适配系统用于执行上文所述的用于无人机自动机场的动态密度屏幕适配方法。The present invention also provides a dynamic density screen adaptation system for UAV automatic airports, the dynamic density screen adaptation system is used to perform the above-mentioned dynamic density screen adaptation for UAV automatic airports method.
实施本发明用于无人机自动机场的动态密度屏幕适配方法及系统的技术方案,具有如下优点或有益效果:本发明创造性以设计图纸的宽度dp作为统一基准,让不同分辨率不同尺寸的Android智能终端的屏幕宽度都变成与设计图纸的宽度dp一致。推导计算新的安卓密度系数density和屏幕像素密度dpi,动态修改Android系统的density和dpi。而且不仅可用于新开发的项目,还可用于已开发完成的项目,对于已开发完成的Android应用,只需要简单地加入几行代码就能实现,而不需要修改原来的代码。从而实现设计图纸的动态适配不同的智能终端屏幕,性能消耗小,对代码侵入性极低,成本极低。Implementing the technical scheme of the dynamic density screen adaptation method and system for the UAV automatic airport of the present invention has the following advantages or beneficial effects: the inventiveness of the present invention takes the width dp of the design The screen width of the Android smart terminal becomes the same as the width dp of the design drawing. Derive and calculate the new Android density coefficient density and screen pixel density dpi, and dynamically modify the density and dpi of the Android system. And it can be used not only for newly developed projects, but also for projects that have been developed. For Android applications that have been developed, it can be implemented simply by adding a few lines of code without modifying the original code. Therefore, the design drawings can be dynamically adapted to different smart terminal screens, with low performance consumption, extremely low code intrusion, and extremely low cost.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例描述中所需要使用的附图作简单的介绍,显而易见,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图,附图中:In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, on the premise of no creative work, other drawings can also be obtained from these drawings, in the drawings:
图1是现有技术的屏幕宽高不同的智能终端显示的百分比布局示意图;1 is a schematic diagram of a percentage layout displayed by an intelligent terminal with different screen widths and heights in the prior art;
图2是本发明用于无人机自动机场的动态密度屏幕适配方法实施例的流程示意图;2 is a schematic flow chart of an embodiment of a dynamic density screen adaptation method for UAV automatic airports according to the present invention;
图3是本发明用于无人机自动机场的动态密度屏幕适配方法实施例的设备1显示示意图;3 is a schematic display diagram of the device 1 according to the embodiment of the dynamic density screen adaptation method for the drone automatic airport according to the present invention;
图4是本发明用于无人机自动机场的动态密度屏幕适配方法实施例的设备2显示示意图。FIG. 4 is a schematic display diagram of the device 2 according to the embodiment of the dynamic density screen adaptation method for the drone automatic airport of the present invention.
具体实施方式Detailed ways
为了使本发明的目的、技术方案及优点更加清楚明白,下文将要描述的各种示例性实施例将要参考相应的附图,这些附图构成了示例性实施例的一部分,其中描述了实现本发明可能采用的各种示例性实施例,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。应明白,它们仅是与如所附权利要求书中所详述的、本发明公开的一些方面相一致的装置和方法的例子,还可使用其他的实施例,或者对本文列举的实施例进行结构和功能上的修改,而不会脱离本发明的范围和实质。在其他情况中,省略对众所周知的系统、装置、电路以及方法的详细说明,以免不必要的细节妨碍本实用新型的描述。In order to make the objects, technical solutions and advantages of the present invention more clearly understood, various exemplary embodiments to be described hereinafter will be referred to the corresponding accompanying drawings, which form a part of the exemplary embodiments in which the implementation of the present invention is described. Various exemplary embodiments may be employed, unless otherwise indicated, the same numerals in the different figures refer to the same or similar elements. The implementations described in the illustrative examples below are not intended to represent all implementations consistent with this disclosure. It is to be understood that these are merely examples of apparatus and methods consistent with some aspects of the present disclosure, as detailed in the appended claims, and that other embodiments may be used, or that the embodiments recited herein may be used. Structural and functional modifications can be made without departing from the scope and spirit of the present invention. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
在本发明的描述中,需要理解的是,术语px是指屏幕的像素点数,即屏幕上的点,与密度相关;dpi是指像素密度,即每英寸的像素点数,数值越高当然显示越清晰,常见取值120、160、240等。dp是指与密度无关像素,Android特有的长度单位,在定义UI布局时应使用的虚拟像素单位,用于以密度无关方式表示布局维度或位置。密度无关像素dp等于160dpi屏幕上的一个物理像素。dp单位转换为屏幕像素很简单:px=dp*(dpi/160)。例如,在240dpi屏幕上,1dp等于1.5物理像素。density是指Android密度系数,一个通过计算得出的比列值,即density=dpi/160(像素/英寸)。分辨率是指屏幕纵横两个方向的像素点的数量,假如屏幕分辨率为1920*1080,则表示屏幕高度上有1920个像素点,宽度上有1080个像素点。屏幕尺寸是指屏幕对角线的长度。需要说明的是,除非另有明确的规定和限定,对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the description of the present invention, it should be understood that the term px refers to the number of pixels on the screen, that is, the dots on the screen, which is related to the density; dpi refers to the pixel density, that is, the number of pixels per inch. The higher the value, the better the display. Clear, common values are 120, 160, 240, etc. dp refers to density-independent pixels, an Android-specific length unit, and a virtual pixel unit that should be used when defining UI layouts to represent layout dimensions or positions in a density-independent manner. Density independent pixel dp is equal to one physical pixel on a 160dpi screen. Converting dp units to screen pixels is simple: px=dp*(dpi/160). For example, on a 240dpi screen, 1dp equals 1.5 physical pixels. Density refers to the Android density coefficient, a calculated ratio value, that is, density=dpi/160 (pixels/inch). Resolution refers to the number of pixels in the vertical and horizontal directions of the screen. If the screen resolution is 1920*1080, it means that the screen has 1920 pixels in height and 1080 pixels in width. Screen size refers to the length of the diagonal of the screen. It should be noted that, unless otherwise clearly specified and limited, those of ordinary skill in the art can understand the specific meanings of the above terms in the present invention according to specific situations.
为了说明本发明所述的技术方案,下面通过具体实施例来进行说明。In order to illustrate the technical solutions of the present invention, the following specific embodiments are used for description.
实施例一:Example 1:
如图2-4示出了本发明用于无人机自动机场的动态密度屏幕适配方法、存储介质、装置及系统施例提供的示意图,为了便于说明,仅示出了与本发明实施例相关的部分。本发明动态密度屏幕适配方法,包括步骤:Figures 2-4 show schematic diagrams provided by the embodiments of the dynamic density screen adaptation method, storage medium, device and system for drone automatic airports according to the present invention. For convenience of description, only the embodiments of the present invention are shown. relevant part. The dynamic density screen adaptation method of the present invention includes the steps:
S10、获取设计图纸的横向虚拟像素值dp;具体的,所述设计图纸的横向虚拟像素值dp从设计图纸的标注说明获得;S10, obtaining the horizontal virtual pixel value dp of the design drawing; specifically, the horizontal virtual pixel value dp of the design drawing is obtained from the annotation description of the design drawing;
S20、动态获取屏幕分辨率的横向像素值px;S20. Dynamically obtain the horizontal pixel value px of the screen resolution;
S30、计算新的安卓密度系数density和屏幕像素密度dpi;S30, calculate the new Android density coefficient density and screen pixel density dpi;
S40、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi。S40, replace the old Android density factor density and screen pixel density dpi with the new Android density factor density and screen pixel density dpi.
具体的,屏幕像素密度dpi的计算公式为:Specifically, the calculation formula of the screen pixel density dpi is:
其中,dp和px换算关系:px=dp*(dpi/160)Among them, the conversion relationship between dp and px: px=dp*(dpi/160)
安卓密度系数:density=dpi/160,且由上面的换算公式可得:px=density*dp。由于Android智能设备的屏幕碎片化严重,碎片化指的是屏幕的分辨率不同或者尺寸不同。Android density coefficient: density=dpi/160, and It can be obtained from the above conversion formula: px=density*dp. Since the screen of Android smart devices is seriously fragmented, fragmentation refers to the different resolutions or sizes of the screens.
如图3-4所示,假如有两台Android智能终端,屏幕分辨率都是1920*1200,设备1是8寸多,设备2是9寸多,UI设计师设计了一张960dp×600dp的图纸,其在两个设备的屏幕显示分别如图3、图4所示,从示例图中可以看出,屏幕分辨率相同的两个设备由于尺寸大小的不同,导致Android设备1的密度系数值density为2.0,屏幕宽度为960dp;而Android设备2的密度系数值density为1.5,屏幕宽度为1280dp。因此,同样dp值的UI控件在两个设备的显示效果是不一样的,Android设备2右边明显有空白留出。As shown in Figure 3-4, if there are two Android smart terminals, the screen resolution is 1920*1200, device 1 is more than 8 inches, device 2 is more than 9 inches, the UI designer designed a 960dp × 600dp The drawings are displayed on the screens of the two devices as shown in Figure 3 and Figure 4 respectively. It can be seen from the example diagram that the two devices with the same screen resolution are different in size, resulting in the density coefficient value of Android device 1. The density is 2.0, and the screen width is 960dp; while the density coefficient value of Android device 2 is 1.5, and the screen width is 1280dp. Therefore, the display effects of UI controls with the same dp value are different on the two devices, and there is obviously a blank space on the right side of Android device 2.
换言之,UI设计师的设计图纸是960dp×600dp,那么这张图纸放到设备1中肯定是没问题的,因为设备1的屏幕宽度刚好为960dp,是可以填满整个屏幕的;但是将这张图纸放到设备2中就无法填满整个屏幕,因为设备2的屏幕宽度为1280dp,大于设计图纸的宽度。如果能把设备2的屏幕宽度变为960dp,适配问题不就迎刃而解了。根据公式px=density*dp可知,分辨率px是固定不变的,修改设备2的屏幕宽度dp值为960,只要改变密度系数density值就可以,也就是 In other words, the design drawing of the UI designer is 960dp×600dp, so it is no problem to put this drawing in device 1, because the screen width of device 1 is just 960dp, which can fill the entire screen; If the drawing is placed in Device 2, it cannot fill the entire screen, because the screen width of Device 2 is 1280dp, which is larger than the width of the design drawing. If the screen width of device 2 can be changed to 960dp, the adaptation problem will not be solved. According to the formula px=density*dp, the resolution px is fixed, and the screen width dp value of device 2 is modified to 960, as long as the density coefficient density value is changed, that is
简而言之,只需要根据推导公式去动态改变Android智能终端密度系数density的值,就能对屏幕的虚拟像素值(宽度)dp进行缩放从而达到屏幕适配的效果。需要注意的是,由于density=dpi/160,为了防止Android系统根据该公式又把density给复原了,因此,在修改Android系统density值的同时,也需要把屏幕像素密度dpi修改为dpi=160*density。In short, it is only necessary to derive the formula according to To dynamically change the value of the density coefficient density of the Android smart terminal, the virtual pixel value (width) dp of the screen can be scaled to achieve the effect of screen adaptation. It should be noted that, since density=dpi/160, in order to prevent the Android system from restoring density according to this formula, when modifying the density value of the Android system, it is also necessary to modify the screen pixel density dpi to dpi=160* density.
在本实施例中,所述S40、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi,具体包括步骤:In this embodiment, the S40, using the new Android density coefficient density and screen pixel density dpi to replace the old Android density coefficient density and screen pixel density dpi, specifically includes the steps:
S410、利用新的安卓密度系数density和屏幕像素密度dpi替换旧的安卓密度系数density和屏幕像素密度dpi;S410, use the new Android density coefficient density and screen pixel density dpi to replace the old Android density coefficient density and screen pixel density dpi;
S420、更新Android系统的Display Metrics对象;S420. Update the Display Metrics object of the Android system;
S430、对UI界面布局进行渲染。S430. Render the UI interface layout.
在本实施例中,所述S20、动态获取屏幕分辨率的横向像素值px,具体包括步骤:In this embodiment, the S20, dynamically obtaining the horizontal pixel value px of the screen resolution, specifically includes the steps:
通过Android系统的Display Metrics对象中动态获取屏幕分辨率的横向像素值px。The horizontal pixel value px of the screen resolution is dynamically obtained from the Display Metrics object of the Android system.
本发明具体使用方法(涉及到程序代码开发):The specific use method of the present invention (relates to program code development):
(1)在Android代码项目中,找到BaseActivity.java窗口基类文件,并在BaseActivity.java文件中的onCreate()方法中调用如下代码。(1) In the Android code project, find the BaseActivity.java window base class file, and call the following code in the onCreate() method in the BaseActivity.java file.
(2)按照原始的设计图纸中横向宽度dp值去替换掉下面代码中的“360”即可。假如原始的设计图纸宽度是1028dp,那么“360”修改为1028。(2) Replace "360" in the following code according to the horizontal width dp value in the original design drawing. If the original design drawing width is 1028dp, then "360" is changed to 1028.
调用的代码:Called code:
在使用本发明方法后,在不同屏幕宽度的Android智能终端使用具有明显效果,简单来说就是横向缩放的效果,相当于一张图片横向缩小或者横向放大的效果,从横向这个维度看,缩放后的图片虽然大小变了,但还是能基本维持图片本身的样子,进而实现适配的目的。另外,本发明并不关心Android智能终端的屏幕宽度是多少,本发明关心的是UI设计师给出的原始的设计图纸的宽度,假如给出的原始的设计图纸宽度是1028dp,使用了本发明进行应用开发来适配,那么开发出来的app,安装到不同的Android智能终端上的效果是:1)如果屏幕宽度是1028dp的Android智能终端,那就刚刚好,横向上图片不会变瘦也不会变胖;2)如果屏幕宽度是960dp的Android智能终端,那么横向上图片会缩小(变瘦),但图片的样子能基本维持;3)如果屏幕宽度是1920dp的Android智能终端,那么横向上图片会放大(变胖),但图片的样子能基本维持;4)所谓屏幕适配不是说大小形状完完全全一模一样的意思,而是能维持基本的图片样貌。After using the method of the present invention, it has obvious effects when used on Android smart terminals with different screen widths. In short, it is the effect of horizontal scaling, which is equivalent to the effect of horizontally shrinking or horizontally enlarging a picture. From the horizontal dimension, after scaling Although the size of the picture has changed, it can still basically maintain the appearance of the picture itself, so as to achieve the purpose of adaptation. In addition, the present invention does not care about the screen width of the Android smart terminal, the present invention is concerned with the width of the original design drawing given by the UI designer, if the given original design drawing width is 1028dp, the present invention is used For application development to adapt, then the developed app will be installed on different Android smart terminals. The effect is: 1) If the screen width is an Android smart terminal of 1028dp, it is just right, and the picture will not become thinner in the horizontal direction. Will not become fat; 2) If the screen width is 960dp Android smart terminal, then the horizontal picture will shrink (thinner), but the image can be basically maintained; 3) If the screen width is 1920dp Android smart terminal, then horizontal The above picture will be enlarged (fat), but the appearance of the picture can be basically maintained; 4) The so-called screen adaptation does not mean that the size and shape are exactly the same, but can maintain the basic picture appearance.
在大部分情况下,设计师只设计一套UI设计图纸给开发人员进行界面开发,设计图纸的宽高与智能终端屏幕的宽高不一定是相等的。由于不同智能终端会有不同的屏幕宽高,而设计图纸通常只有一套,故可以把设计图纸的宽高作为基准,来适配不同分辨率的智能终端屏幕。以设计图纸宽高为基准,结合实际智能终端屏幕宽高,来计算出修正值去动态修改系统的density和dpi,从而将设计图纸以缩放的方式去适配不同的智能终端屏幕。由于系统的density和dpi只需修改一次就能生效,没有性能消耗的问题;一次调用也意味着对代码侵入性极低,且该方法的核心是基准缩放显示,不需要改动任何原有布局文件,成本极低。In most cases, designers only design a set of UI design drawings for developers to develop the interface. The width and height of the design drawings and the width and height of the smart terminal screen are not necessarily equal. Since different smart terminals have different screen widths and heights, and there is usually only one set of design drawings, the width and height of the design drawings can be used as a benchmark to adapt to smart terminal screens of different resolutions. Based on the width and height of the design drawings, combined with the width and height of the actual smart terminal screen, the correction value is calculated to dynamically modify the density and dpi of the system, so that the design drawings can be scaled to fit different smart terminal screens. Since the density and dpi of the system only need to be modified once to take effect, there is no performance consumption problem; one call also means that the code intrusion is extremely low, and the core of this method is the benchmark zoom display, no need to change any original layout files. , the cost is very low.
对于已经开发完成的且没有做屏幕适配的Android应用产品来说,使用该方法进行后期的屏幕适配工作,成本非常低,甚至可以说是忽略不计,因为它不需要修改原本的任何xml布局文件,这在现实的Android屏幕适配开发工作中,具有很高的运用价值。For Android application products that have been developed without screen adaptation, the cost of using this method for later screen adaptation is very low, and it can even be said to be negligible, because it does not need to modify any original xml layout. file, which has high application value in the actual Android screen adaptation development work.
对于开发初期就选择该方法进行屏幕适配的的Android开发者来说,整个界面开发过程只需完全按照UI设计图中标注的尺寸去设置UI控件的宽高即可,不用再考虑屏幕适配问题,让开发者的界面开发工作更加专注集中且简单高效。For Android developers who choose this method for screen adaptation in the early stage of development, the entire interface development process only needs to set the width and height of UI controls according to the dimensions marked in the UI design drawing, without considering screen adaptation. problems, making the developer's interface development work more focused, simple and efficient.
使用该方法进行Android的屏幕适配,由于方法核心是在界面加载渲染之前改变Android系统的像素密度,且一次设置全局有效,避免了百分比方案中UI控件每次渲染绘制时的计算成本,所以大大提升了应用的性能,使得应用产品更加流畅与稳定。Using this method for Android screen adaptation, because the core of the method is to change the pixel density of the Android system before the interface is loaded and rendered, and the one-time setting is globally effective, it avoids the calculation cost of each rendering and drawing of the UI controls in the percentage scheme, so it is greatly Improve the performance of the application, making the application product more smooth and stable.
本发明创造性以设计图纸的宽度dp作为统一基准,让不同分辨率不同尺寸的Android智能终端的屏幕宽度都变成与设计图纸的宽度dp一致。推导计算新的安卓密度系数density和屏幕像素密度dpi,动态修改Android系统的density和dpi,从而实现设计图纸的动态适配不同的智能终端屏幕,性能消耗小,对代码侵入性极低,成本极低。The invention creatively uses the width dp of the design drawings as a unified benchmark, so that the screen widths of Android smart terminals with different resolutions and sizes are consistent with the width dp of the design drawings. Derive and calculate the new Android density coefficient density and screen pixel density dpi, dynamically modify the density and dpi of the Android system, so as to realize the dynamic adaptation of design drawings to different smart terminal screens, with low performance consumption, extremely low code intrusion, and extremely high cost Low.
实施例二:Embodiment 2:
本领域普通技术人员可以理解,实现上述各方法实施例的全部或部分步骤可以通过计算机程序相关的硬件来完成。前述的计算机程序可以存储于一计算机可读的存储介质中,存储介质上存储有计算机程序,所述计算机程序被(如处理器)执行时,执行包括上述的用于无人机自动机场的动态密度屏幕适配方法实施例的步骤,而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by hardware related to computer programs. The aforementioned computer program can be stored in a computer-readable storage medium, and the storage medium is stored with a computer program, and when the computer program is executed (such as a processor), the execution includes the above-mentioned dynamic for the UAV automatic airport. The steps of the embodiment of the density screen adaptation method, and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
实施例三:Embodiment three:
本发明还提供一种动态密度屏幕适配装置实施例,包括处理器及存储器;其中,所述存储器用于存储计算机程序,所述处理器用于执行存储器存储的计算机程序,以使处理器执行上述的用于无人机自动机场的动态密度屏幕适配方法实施例的步骤。The present invention also provides an embodiment of a dynamic density screen adaptation device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the processor executes the above The steps of an embodiment of a dynamic density screen adaptation method for a drone automatic airport.
实施例四:Embodiment 4:
本发明还提供一种用于无人机自动机场的动态密度屏幕适配系统,所述动态密度屏幕适配系统用于执行如实施例一所述的用于无人机自动机场的动态密度屏幕适配方法。The present invention also provides a dynamic density screen adaptation system for drone automatic airports, the dynamic density screen adaptation system is used to implement the dynamic density screen for drone automatic airports as described in the first embodiment adaptation method.
在阅读完下面将要描述的内容之后,本领域的技术人员应当明白,本文描述的各种特征可通过方法、数据处理系统或计算机程序产品来实现。因此,这些特征可部采用硬件的方式、全部采用软件的方式或者采用硬件和软件结合的方式来表现。此外,上述特征也可采用存储在一种或多种计算机可读存储介质上的计算机程序产品的形式来表现,该计算机可读存储介质中包含计算机可读程序代码段或者指令,其存储在存储介质中。可读存储介质被配置为存储各种类型的数据以支持在装置的操作。可读存储介质可以由任何类型的易失性或非易失性存储设备或者它们的组合实现。如静硬盘、态随机存取存储器(SRAM)、电可擦除可编程只读存储器(EEPROM)、可擦除可编程只读存储器(EPROM)、可编程只读存储器(PROM)、只读存储器(ROM)、光存储设备、磁存储设备、快闪存储器、磁盘或光盘和/或上述设备的组合。After reading what is described below, one skilled in the art should appreciate that the various features described herein can be implemented by a method, data processing system or computer program product. Accordingly, these features may be expressed partly in hardware, entirely in software, or in a combination of hardware and software. Furthermore, the above-described features may also take the form of a computer program product stored on one or more computer-readable storage media containing computer-readable program code segments or instructions stored in a storage medium in the medium. The readable storage medium is configured to store various types of data to support operation of the device. A readable storage medium can be implemented by any type of volatile or nonvolatile storage device or a combination thereof. Such as static hard disk, state 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), optical storage devices, magnetic storage devices, flash memory, magnetic or optical disks and/or combinations thereof.
以上仅为本发明的较佳实施例而已,本领域技术人员知悉,在不脱离本发明的精神和范围的情况下,可以对这些特征和实施例进行各种改变或等同替换。另外,在本发明的教导下,可以对这些特征和实施例进行修改以适应具体的情况及材料而不会脱离本发明的精神和范围。因此,本发明不受此处所公开的具体实施例的限制,所有落入本申请的权利要求范围内的实施例都属于本发明的保护范围。The above are only preferred embodiments of the present invention, and those skilled in the art know that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, in the teachings of this invention, these features and embodiments may be modified to adapt a particular situation and material without departing from the spirit and scope of the invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of the present application belong to the protection scope of the present invention.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910275990.2A CN110007919A (en) | 2019-04-08 | 2019-04-08 | A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910275990.2A CN110007919A (en) | 2019-04-08 | 2019-04-08 | A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN110007919A true CN110007919A (en) | 2019-07-12 |
Family
ID=67170266
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201910275990.2A Pending CN110007919A (en) | 2019-04-08 | 2019-04-08 | A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN110007919A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111443974A (en) * | 2020-03-26 | 2020-07-24 | 中国农业银行股份有限公司 | Android device screen adapting method, related device and readable storage medium |
| CN112596842A (en) * | 2020-12-26 | 2021-04-02 | 中国农业银行股份有限公司 | Screen adaptation method for android system SDK development and related device |
| CN114356464A (en) * | 2020-10-13 | 2022-04-15 | 阿里巴巴集团控股有限公司 | User interface adaptation method, rendering method, device, equipment and storage medium |
| CN114610426A (en) * | 2022-03-04 | 2022-06-10 | 腾讯科技(深圳)有限公司 | A method, device, device and storage medium for adjusting interface layout |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20150347097A1 (en) * | 2014-05-30 | 2015-12-03 | Apple Inc. | Adaptive user interfaces |
| CN105187634A (en) * | 2015-08-07 | 2015-12-23 | 北京思特奇信息技术股份有限公司 | Method and system for enabling terminal application to dynamically adapt to intelligent terminal screen |
| CN107092479A (en) * | 2017-03-17 | 2017-08-25 | 武汉斗鱼网络科技有限公司 | Screen adaptation method and system for Android widescreen equipment |
| CN109542550A (en) * | 2018-10-19 | 2019-03-29 | 新博卓畅技术(北京)有限公司 | A kind of screen adaptation method, system and equipment based on dynamic setting screen density |
-
2019
- 2019-04-08 CN CN201910275990.2A patent/CN110007919A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20150347097A1 (en) * | 2014-05-30 | 2015-12-03 | Apple Inc. | Adaptive user interfaces |
| CN105187634A (en) * | 2015-08-07 | 2015-12-23 | 北京思特奇信息技术股份有限公司 | Method and system for enabling terminal application to dynamically adapt to intelligent terminal screen |
| CN107092479A (en) * | 2017-03-17 | 2017-08-25 | 武汉斗鱼网络科技有限公司 | Screen adaptation method and system for Android widescreen equipment |
| CN109542550A (en) * | 2018-10-19 | 2019-03-29 | 新博卓畅技术(北京)有限公司 | A kind of screen adaptation method, system and equipment based on dynamic setting screen density |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111443974A (en) * | 2020-03-26 | 2020-07-24 | 中国农业银行股份有限公司 | Android device screen adapting method, related device and readable storage medium |
| CN114356464A (en) * | 2020-10-13 | 2022-04-15 | 阿里巴巴集团控股有限公司 | User interface adaptation method, rendering method, device, equipment and storage medium |
| CN112596842A (en) * | 2020-12-26 | 2021-04-02 | 中国农业银行股份有限公司 | Screen adaptation method for android system SDK development and related device |
| CN114610426A (en) * | 2022-03-04 | 2022-06-10 | 腾讯科技(深圳)有限公司 | A method, device, device and storage medium for adjusting interface layout |
| CN114610426B (en) * | 2022-03-04 | 2023-09-08 | 腾讯科技(深圳)有限公司 | Method, device, equipment and storage medium for adjusting interface layout |
| US12487735B2 (en) | 2022-03-04 | 2025-12-02 | Tencent Technology (Shenzhen) Company Limited | Method and apparatus for adjusting interface layout, device, and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110007919A (en) | A kind of dynamic density screen adaptation method and system for the automatic airport of unmanned plane | |
| CN109389661B (en) | Animation file conversion method and device | |
| CN111324381B (en) | Development system, development method, development apparatus, computer device, and storage medium | |
| US20160098250A1 (en) | Application prototyping tool | |
| WO2015131787A1 (en) | Screen adaptation method and apparatus | |
| US10657705B2 (en) | System and method for rendering shadows for a virtual environment | |
| CN109671147B (en) | Texture map generation method and device based on three-dimensional model | |
| CN111951356B (en) | Animation rendering method based on JSON data format | |
| CN108897541B (en) | Visual restoration method and device of application program, storage medium and terminal | |
| US20150074519A1 (en) | Method and apparatus of controlling page element | |
| CN111352627B (en) | Page skeleton screen generation method, device, equipment and readable storage medium | |
| CN107562498A (en) | Animation effect implementation method, device and terminal device based on Android platform | |
| CN106204439A (en) | The method and system of picture self-adaptive processing | |
| CN112700519A (en) | Animation display method and device, electronic equipment and computer readable storage medium | |
| CN111459501A (en) | SVG-based Web configuration picture storage and display system, method and medium | |
| EP4231243A1 (en) | Data storage management method, object rendering method, and device | |
| US9817795B2 (en) | Document layout for electronic displays | |
| CN116010736B (en) | Methods, devices, equipment, and storage media for processing vector icons. | |
| CN110502305B (en) | Method and device for realizing dynamic interface and related equipment | |
| CN115640044B (en) | Unity-based three-dimensional software development method, device, equipment and medium | |
| CN110782504A (en) | Curve determination method, device, computer readable storage medium and equipment | |
| CN106296575A (en) | Model based on BIM and picture merge and separation method and system | |
| CN109933323A (en) | A kind of method and device that user interface is set | |
| CN113963083A (en) | Programming building block drawing method, building block building method and device and electronic equipment | |
| CN113253959B (en) | Front-end screen projection method adaptive to different large screen resolutions |
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 | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190712 |