CN106648700A - Display method and device compatible with different resolution ratios - Google Patents
Display method and device compatible with different resolution ratios Download PDFInfo
- Publication number
- CN106648700A CN106648700A CN201611270844.3A CN201611270844A CN106648700A CN 106648700 A CN106648700 A CN 106648700A CN 201611270844 A CN201611270844 A CN 201611270844A CN 106648700 A CN106648700 A CN 106648700A
- Authority
- CN
- China
- Prior art keywords
- layout
- configuration file
- resolution
- display device
- resolution ratio
- 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
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
- G06F9/4451—User profiles; Roaming
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
Description
技术领域technical field
本发明涉及电视技术领域,尤其涉及一种兼容不同分辨率的显示方法和装置。The invention relates to the technical field of television, in particular to a display method and device compatible with different resolutions.
背景技术Background technique
一般地,智能电视应用项目开发中,企业都会基于一个基础机芯派生多个不同尺寸、不同分辨率的项目,所以开发一款android电视应用时,都必须要考虑设计兼容所有分辨率和尺寸,然而谷歌提供的Android自适应兼容方案,开发人员必须针对不同的分辨率设计不同界面布局文件,且每种分辨率中加载不同的图片,不仅无形加大开发的工作量,且最终因打包的图片过多造成最终输出的应用安装包过大,与电视低成本低内存相互冲突,不利于发展需求。因此开发一种可兼容不同分辨率的布局的系统且能减少开发的工作量,并能减少系统所占的内存成为目前需要解决的技术问题。Generally, in the development of smart TV application projects, companies will derive multiple projects of different sizes and resolutions based on a basic core. Therefore, when developing an android TV application, it must be considered that the design is compatible with all resolutions and sizes. However, for the Android adaptive compatibility solution provided by Google, developers must design different interface layout files for different resolutions, and load different pictures in each resolution, which not only invisibly increases the workload of development, but also ultimately results in Too many will cause the final output application installation package to be too large, which conflicts with the low cost and low memory of the TV, which is not conducive to development needs. Therefore, developing a system that is compatible with layouts of different resolutions, can reduce the development workload, and can reduce the memory occupied by the system has become a technical problem that needs to be solved at present.
发明内容Contents of the invention
本发明的主要目的在于提供一种兼容不同分辨率的显示方法和装置,旨在实现兼容不同分辨率的页面显示。The main purpose of the present invention is to provide a display method and device compatible with different resolutions, aiming at realizing page display compatible with different resolutions.
为实现上述目的,本发明提供的一种兼容不同分辨率的显示方法包括以下步骤:In order to achieve the above purpose, a display method compatible with different resolutions provided by the present invention includes the following steps:
获取当前显示设备的分辨率;Get the resolution of the current display device;
根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;Read the target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device;
根据获取到的目标布局参数在当前设备上显示页面布局。Display the page layout on the current device according to the obtained target layout parameters.
优选地,所述布局配置文件为Xml格式的文件。Preferably, the layout configuration file is a file in Xml format.
优选地,所述根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数的步骤包括:Preferably, the step of reading target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device includes:
判断获取到的当前显示设备的分辨率在布局配置文件中是否存在于所述分辨率对应的布局配置文件;Judging whether the acquired resolution of the current display device exists in the layout configuration file corresponding to the resolution in the layout configuration file;
若存在,则读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;If it exists, read the target layout parameters corresponding to the resolution of the current display device in the layout configuration file;
若不存在,则在预设的布局文件中获取默认的目标布局参数。If it does not exist, get the default target layout parameters in the preset layout file.
优选地,所述布局配置文件中对应的目标布局参数中的布局单位为px。Preferably, the layout unit in the corresponding target layout parameter in the layout configuration file is px.
优选地,所述根据获取到的当前显示设备的分辨率读取Xml文件中对应的当前显示设备的分辨率对应的目标参数信息的步骤之前还包括:Preferably, before the step of reading the target parameter information corresponding to the resolution of the current display device in the Xml file according to the acquired resolution of the current display device, the step further includes:
在布局配置文件中写入显示设备中常见分辨率的布局参数。Write layout parameters for common resolutions in the display device in the layout configuration file.
此外,为实现上述目的,本发明还提供一种兼容不同分辨率的显示装置,所述兼容不同分辨率的显示装置包括:In addition, in order to achieve the above object, the present invention also provides a display device compatible with different resolutions, and the display device compatible with different resolutions includes:
获取模块,用于获取当前显示设备的分辨率;The acquisition module is used to acquire the resolution of the current display device;
读取模块,用于根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;A reading module, configured to read target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device;
显示模块,用于根据获取到的目标布局参数在当前设备上显示页面布局。The display module is used to display the page layout on the current device according to the acquired target layout parameters.
优选地,所述布局配置文件为Xml格式的文件。Preferably, the layout configuration file is a file in Xml format.
优选地,所述读取模块包括:Preferably, the reading module includes:
判断单元,用于判断获取到的当前显示设备的分辨率在布局配置文件中是否存在于所述分辨率对应的布局配置文件;A judging unit, configured to judge whether the acquired resolution of the current display device exists in the layout configuration file corresponding to the resolution in the layout configuration file;
读取单元,用于当布局配置文件中存在当前显示设备对应的布局配置文件时,则读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;The reading unit is used to read target layout parameters corresponding to the resolution of the current display device in the layout configuration file when there is a layout configuration file corresponding to the current display device in the layout configuration file;
获取单元,用于当布局配置文件中不存在当前显示设备对应的布局配置文件时,则在预设的布局文件中获取默认的目标布局参数。The obtaining unit is used to obtain default target layout parameters in a preset layout file when there is no layout configuration file corresponding to the current display device in the layout configuration file.
优选地,所述布局配置文件中对应的目标布局参数中的布局单位为px。Preferably, the layout unit in the corresponding target layout parameter in the layout configuration file is px.
优选地,所述兼容不同分辨率的显示装置还包括:Preferably, the display device compatible with different resolutions further includes:
写入模块,用于在布局配置文件中写入显示设备中常见分辨率的布局参数。The write module is used to write the layout parameters of common resolutions in the display device in the layout configuration file.
本发明通过获取当前显示设备的分辨率;根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;根据获取到的目标布局参数在当前设备上显示页面布局。采用本发明的方法,实现了显示设备不同分辨率下的页面布局。The present invention obtains the resolution of the current display device; reads the target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the obtained resolution of the current display device; The page layout is displayed on the device. By adopting the method of the invention, page layouts under different resolutions of display devices are realized.
附图说明Description of drawings
图1为本发明兼容不同分辨率的显示方法第一实施例的流程示意图;FIG. 1 is a schematic flowchart of a first embodiment of a display method compatible with different resolutions according to the present invention;
图2为本发明兼容不同分辨率的显示方法第二实施例的流程示意图;FIG. 2 is a schematic flowchart of a second embodiment of a display method compatible with different resolutions according to the present invention;
图3为本发明兼容不同分辨率的显示装置第一实施例的功能模块示意图;3 is a schematic diagram of the functional modules of the first embodiment of the display device compatible with different resolutions of the present invention;
图4为本发明兼容不同分辨率的显示装置第二实施例的读取模块的细化功能模块示意图。FIG. 4 is a schematic diagram of detailed functional modules of the reading module of the second embodiment of the display device compatible with different resolutions according to the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
本发明提供一种兼容不同分辨率的显示方法,参照图1,在一实施例中,该兼容不同分辨率的显示方法包括:The present invention provides a display method compatible with different resolutions. Referring to FIG. 1, in one embodiment, the display method compatible with different resolutions includes:
步骤S10,获取当前显示设备的分辨率;Step S10, acquiring the resolution of the current display device;
在对本发明实施例提供的兼容不同分辨率的显示方法的方案进行详细介绍和说明之前,首先介绍各个实施例中需要用到的几个单位。Before introducing and illustrating in detail the solutions of display methods compatible with different resolutions provided by the embodiments of the present invention, several units that need to be used in each embodiment are introduced first.
像素单位(px):标示屏幕的实际像素值。Pixel unit (px): indicates the actual pixel value of the screen.
布局大小单位(dp):表示屏幕上与像素密度无关的像素,无论屏幕的像素密度为多少,1英寸=160dp。Layout size unit (dp): indicates the pixels on the screen that have nothing to do with the pixel density, regardless of the pixel density of the screen, 1 inch = 160dp.
其中,密度表示根据像素分辨率,在屏幕指定物理宽高范围内能显示的像素数量。在同样的宽高区域,低密度的显示屏能显示的像素较少,而高密度的显示屏则能显示更多的像素。屏幕密度非常重要,因为其它条件不变的情况下,一共宽高固定的UI组件(比如一个按钮)在低密度的显示屏上显得很大,而在高密度显示屏上看起来就很小(单位为dp时)。Among them, the density indicates the number of pixels that can be displayed within the specified physical width and height range of the screen according to the pixel resolution. In the same area of width and height, a low-density display can display fewer pixels, while a high-density display can display more pixels. Screen density is very important, because other conditions remain unchanged, a UI component with a fixed width and height (such as a button) appears large on a low-density display, and looks small on a high-density display ( when the unit is dp).
本实施例中,通过获取当前显示设备的分辨率,选择与当前显示设备的分辨率匹配的布局方法。其中,所述Xml文件中的布局单位采用px。在同一分辨率,不同密度情况下,设定为固定数值的布局:布局设定单位为px时,只要分辨率不变,密度比变化对显示没有影响。如果设定单位为dp时,分辨率不变,显示会随着密度比变化呈1.5倍放大或者缩小。因此本申请中所述Xml文件中的布局单位采用px。In this embodiment, by acquiring the resolution of the current display device, a layout method matching the resolution of the current display device is selected. Wherein, the layout unit in the Xml file adopts px. In the case of the same resolution and different densities, the layout is set to a fixed value: when the layout setting unit is px, as long as the resolution remains unchanged, the density ratio change has no effect on the display. If the unit is set to dp and the resolution remains unchanged, the display will be enlarged or reduced by 1.5 times as the density ratio changes. Therefore, the layout unit in the Xml file mentioned in this application adopts px.
具体参见以下程序代码:See the following program code for details:
DisplayMetrics metric=new DisplayMetrics();DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);getWindowManager().getDefaultDisplay().getMetrics(metric);
int width=metric.widthPixels;//屏幕宽度(像素)int width=metric.widthPixels;//screen width (pixels)
int height=metric.heightPixels;//屏幕高度(像素)int height=metric.heightPixels;//screen height (pixels)
步骤S20,根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;Step S20, read target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device;
本实施例中,通过预先在布局配置文件中写入显示设备常见的分辨率的布局参数,其中所述的常见的分辨为为1280x720,1920x1080,3840x2160等。其中,所述布置配置文件为Xml格式的文件。对应不同的分辨率,所述Xml文件中存储了与不同分辨率对应的布局参数,所述的布局参数包括文件显示的图片大小、文字大小以及文件布局等。本实施例采用预先在Xml文件中写入相应的布局参数,主要是因为在Xml中写入布局参数,这些参数是可以改变的,如果需要更改的话,只需要更改配置文件即可。但是如果通过直接在代码中设置好固定的布局参数的话,如果需要更改,则需要更改整个代码,给系统的布局带来麻烦。其中所述的布局参数包括页面显示中图片的大小,文字大小以及控件大小等等。In this embodiment, the layout parameters of common resolutions of display devices are pre-written in the layout configuration file, wherein the common resolutions are 1280x720, 1920x1080, 3840x2160 and so on. Wherein, the arrangement configuration file is a file in Xml format. Corresponding to different resolutions, the Xml file stores layout parameters corresponding to different resolutions, and the layout parameters include image size, text size and file layout displayed in the file. In this embodiment, the corresponding layout parameters are written in the Xml file in advance, mainly because the layout parameters are written in the Xml, and these parameters can be changed. If it needs to be changed, only the configuration file needs to be changed. But if you set the fixed layout parameters directly in the code, if you need to change it, you need to change the entire code, which will bring trouble to the layout of the system. The layout parameters mentioned therein include the size of the picture in the page display, the size of the text, the size of the control and so on.
具体参见以下程序代码:See the following program code for details:
switch(height){switch(height){
case 720:case 720:
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(140,120));mLayout.setLayoutParams(new LayoutParams)(140,120));
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
Break;break;
case 1080;case 1080;
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(210,180));mLayout.setLayoutParams(new LayoutParams)(210,180));
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
Break;break;
case 2160;case 2160;
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(420,360);mLayout.setLayoutParams(new LayoutParams)(420,360);
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
break;break;
default:default:
break;break;
}}
pareat layout.addview(mLayout)pareat layout. addview(mLayout)
}}
步骤S30,根据获取到的目标布局参数在当前设备上显示页面布局;Step S30, displaying the page layout on the current device according to the acquired target layout parameters;
本实施例中,根据在Xml文件中获取到的目标布局参数在当前显示设备上显示页面布局。In this embodiment, the page layout is displayed on the current display device according to the target layout parameters obtained in the Xml file.
本发明实施例通过获取当前显示设备的分辨率;根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;根据获取到的目标布局参数在当前设备上显示页面布局。采用本实施例的方法,可以实现不同分辨率的显示设备的页面布局。In the embodiment of the present invention, by acquiring the resolution of the current display device; reading the target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device; according to the acquired target layout parameters Displays the page layout on the current device. By adopting the method of this embodiment, page layouts of display devices with different resolutions can be realized.
进一步地,参照图2,基于本发明兼容不同分辨率的显示方法第一实施例,在本发明兼容不同分辨率的显示方法第二实施例中,所述步骤S20包括:Further, referring to FIG. 2, based on the first embodiment of the display method compatible with different resolutions of the present invention, in the second embodiment of the display method compatible with different resolutions of the present invention, the step S20 includes:
步骤S21,判断获取到的当前显示设备的分辨率在布局配置文件中是否存在于所述分辨率对应的目标布局参数;Step S21, judging whether the acquired resolution of the current display device exists in the target layout parameter corresponding to the resolution in the layout configuration file;
步骤S22,若存在,则读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;Step S22, if it exists, read the target layout parameters corresponding to the resolution of the current display device in the layout configuration file;
步骤S23,若不存在,则在预设的布局文件中获取默认的目标布局参数。Step S23, if it does not exist, obtain the default target layout parameters from the preset layout file.
本实施例中,如果所述写入了显示设备的分辨率的布局参数的Xml文件中,没有与当前显示设备的分辨率匹配的参数,则在预设的布局文件中获取默认的目标布局参数。由于目前的电视显示器、手机屏幕或是电脑屏幕等,均有相应的屏幕尺寸标准,对应的设置了标准的几种分辨率,所以Xml文件中写入的是几种常见的分辨率对应的布局参数,而在Xml中没有相匹配的分辨率,则表示当前显示设备的分辨率不是常有的,那么此时在系统里的默认的布局文件中获取默认的布局参数。In this embodiment, if there is no parameter matching the resolution of the current display device in the Xml file in which the layout parameters of the resolution of the display device are written, the default target layout parameters are obtained in the preset layout file . Since the current TV monitors, mobile phone screens, or computer screens all have corresponding screen size standards, and several standard resolutions are set correspondingly, so the layout corresponding to several common resolutions is written in the Xml file parameters, but there is no matching resolution in Xml, it means that the resolution of the current display device is not common, then at this time, obtain the default layout parameters in the default layout file in the system.
本实施例通过判断当前显示设备的分辨率是否为常见的分辨率,或者说是否存在于Xml文件中来分配不同分辨率的布局参数;如果在Xml文件中没有与之对应的分辨率参数,则在默认的布局文件中获取默认的目标布局参数。以此将显示区分为标准和非标准,统一管理,方便应用。This embodiment assigns layout parameters of different resolutions by judging whether the resolution of the current display device is a common resolution, or whether it exists in the Xml file; if there is no corresponding resolution parameter in the Xml file, then Get the default target layout parameters in the default layout file. In this way, the display is divided into standard and non-standard, unified management, and convenient application.
本发明提供一种兼容不同分辨率的显示装置,参照图3,在一实施例中,该兼容不同分辨率的显示装置包括:The present invention provides a display device compatible with different resolutions. Referring to FIG. 3, in one embodiment, the display device compatible with different resolutions includes:
获取模块10,用于获取当前显示设备的分辨率;An acquisition module 10, configured to acquire the resolution of the current display device;
在对本发明实施例提供的兼容不同分辨率的显示方法的方案进行详细介绍和说明之前,首先介绍各个实施例中需要用到的几个单位。Before introducing and illustrating in detail the solutions of display methods compatible with different resolutions provided by the embodiments of the present invention, several units that need to be used in each embodiment are introduced first.
像素单位(px):标示屏幕的实际像素值。Pixel unit (px): indicates the actual pixel value of the screen.
布局大小单位(dp):表示屏幕上与像素密度无关的像素,无论屏幕的像素密度为多少,1英寸=160dp。Layout size unit (dp): indicates the pixels on the screen that have nothing to do with the pixel density, regardless of the pixel density of the screen, 1 inch = 160dp.
其中,密度表示根据像素分辨率,在屏幕指定物理宽高范围内能显示的像素数量。在同样的宽高区域,低密度的显示屏能显示的像素较少,而高密度的显示屏则能显示更多的像素。屏幕密度非常重要,因为其它条件不变的情况下,一共宽高固定的UI组件(比如一个按钮)在低密度的显示屏上显得很大,而在高密度显示屏上看起来就很小(单位为dp时)。Among them, the density indicates the number of pixels that can be displayed within the specified physical width and height range of the screen according to the pixel resolution. In the same area of width and height, a low-density display can display fewer pixels, while a high-density display can display more pixels. Screen density is very important, because other conditions remain unchanged, a UI component with a fixed width and height (such as a button) appears large on a low-density display, and looks small on a high-density display ( when the unit is dp).
本实施例中,通过获取当前显示设备的分辨率,选择与当前显示设备的分辨率匹配的布局方法。其中,所述Xml文件中的布局单位采用px。在同一分辨率,不同密度情况下,设定为固定数值的布局:布局设定单位为px时,只要分辨率不变,密度比变化对显示没有影响。如果设定单位为dp时,分辨率不变,显示会随着密度比变化呈1.5倍放大或者缩小。因此本申请中所述Xml文件中的布局单位采用px。In this embodiment, by acquiring the resolution of the current display device, a layout method matching the resolution of the current display device is selected. Wherein, the layout unit in the Xml file adopts px. In the case of the same resolution and different densities, the layout is set to a fixed value: when the layout setting unit is px, as long as the resolution remains unchanged, the density ratio change has no effect on the display. If the unit is set to dp and the resolution remains unchanged, the display will be enlarged or reduced by 1.5 times as the density ratio changes. Therefore, the layout unit in the Xml file mentioned in this application adopts px.
具体参见以下程序代码:See the following program code for details:
DisplayMetrics metric=new DisplayMetrics();DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);getWindowManager().getDefaultDisplay().getMetrics(metric);
int width=metric.widthPixels;//屏幕宽度(像素)int width=metric.widthPixels;//screen width (pixels)
int height=metric.heightPixels;//屏幕高度(像素)int height=metric.heightPixels;//screen height (pixels)
读取模块20,用于根据获取到的当前显示设备的分辨率读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;The reading module 20 is configured to read target layout parameters corresponding to the resolution of the current display device in the layout configuration file according to the acquired resolution of the current display device;
本实施例中,通过预先在Xml文件中写入显示设备常见的分辨率的布局参数,其中所述的常见的分辨为为1280x720,1920x1080,3840x2160等。其中,所述布置配置文件为Xml格式的文件。对应不同的分辨率,所述Xml文件中存储了与不同分辨率对应的布局参数,所述的布局参数包括文件显示的图片大小、文字大小以及文件布局等。本实施例采用预先在Xml文件中写入相应的布局参数,主要是因为在Xml中写入布局参数,这些参数是可以改变的,如果需要更改的话,只需要更改配置文件即可。但是如果通过直接在代码中设置好固定的布局参数的话,如果需要更改,则需要更改整个代码,给系统的布局带来麻烦。其中所述的布局参数包括页面显示中图片的大小,文字大小以及控件大小等等。In this embodiment, the common resolution layout parameters of the display device are written in the Xml file in advance, wherein the common resolutions are 1280x720, 1920x1080, 3840x2160 and so on. Wherein, the arrangement configuration file is a file in Xml format. Corresponding to different resolutions, the Xml file stores layout parameters corresponding to different resolutions, and the layout parameters include image size, text size and file layout displayed in the file. In this embodiment, the corresponding layout parameters are written in the Xml file in advance, mainly because the layout parameters are written in the Xml, and these parameters can be changed. If it needs to be changed, only the configuration file needs to be changed. But if you set the fixed layout parameters directly in the code, if you need to change it, you need to change the entire code, which will bring trouble to the layout of the system. The layout parameters mentioned therein include the size of the picture in the page display, the size of the text, the size of the control and so on.
具体参见以下程序代码:See the following program code for details:
switch(height){switch(height){
case 720:case 720:
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(140,120));mLayout.setLayoutParams(new LayoutParams)(140,120));
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
Break;break;
case 1080;case 1080;
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(210,180));mLayout.setLayoutParams(new LayoutParams)(210,180));
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
Break;break;
case 2160;case 2160;
mLayout=new LinearLayout(this)mLayout = new LinearLayout(this)
mLayout.setLayoutParams(new LayoutParams)(420,360);mLayout.setLayoutParams(new LayoutParams)(420,360);
mLayout.setGravity(Gravity.RIGHT);mLayout.setGravity(Gravity.RIGHT);
mLayout.SetBackgroundColour(0xff00ff00);mLayout.SetBackgroundColour(0xff00ff00);
break;break;
default:default:
break;break;
}}
pareat layout.addview(mLayout)pareat layout. addview(mLayout)
}}
显示模块30,用于根据获取到的目标布局参数在当前设备上显示页面布局;A display module 30, configured to display the page layout on the current device according to the acquired target layout parameters;
本实施例中,根据在Xml中获取到的目标布局参数在当前显示设备上显示页面布局。In this embodiment, the page layout is displayed on the current display device according to the target layout parameters acquired in Xml.
本发明实施例通过获取当前显示设备的分辨率;根据获取到的当前显示设备的分辨率读取Xml文件中对应的当前显示设备的分辨率对应的目标布局参数;根据获取到的目标布局参数在当前设备上显示页面布局。采用本实施例的方法,可以实现不同分辨率的显示设备的布局。The embodiment of the present invention acquires the resolution of the current display device; reads the target layout parameters corresponding to the resolution of the current display device in the Xml file according to the acquired resolution of the current display device; according to the acquired target layout parameters in Displays the page layout on the current device. By adopting the method of this embodiment, the layout of display devices with different resolutions can be realized.
进一步地,参照图4,基于本发明兼容不同分辨率的显示装置第一实施例,在本发明兼容不同分辨率的显示装置第二实施例中,所述读取模块20包括:Further, referring to FIG. 4 , based on the first embodiment of the display device compatible with different resolutions of the present invention, in the second embodiment of the display device compatible with different resolutions of the present invention, the reading module 20 includes:
判断单元21,用于判断获取到的当前显示设备的分辨率在布局配置文件中是否存在于所述分辨率对应的目标布局参数;A judging unit 21, configured to judge whether the acquired resolution of the current display device exists in the layout configuration file in the target layout parameter corresponding to the resolution;
读取单元22,用于当布局配置文件中存在当前显示设备对应的布局配置文件时,则读取布局配置文件中对应的当前显示设备的分辨率对应的目标布局参数;The reading unit 22 is configured to read target layout parameters corresponding to the resolution of the current display device in the layout configuration file when there is a layout configuration file corresponding to the current display device in the layout configuration file;
获取单元23,用于当布局配置文件中不存在当前显示设备对应的布局配置文件时,则在预设的布局文件中获取默认的目标布局参数。The obtaining unit 23 is configured to obtain default target layout parameters from a preset layout file when there is no layout configuration file corresponding to the current display device in the layout configuration file.
本实施例中,如果所述写入了显示设备的分辨率的布局参数的Xml文件中,没有与当前显示设备的分辨率匹配的参数,则在预设的布局文件中获取默认的目标布局参数。由于目前的电视显示器、手机屏幕或是电脑屏幕等,均有相应的屏幕尺寸标准,对应的设置了标准的几种分辨率,所以Xml文件中写入的是几种常见的分辨率对应的布局参数,而在Xml文件中没有相匹配的分辨率,则表示当前显示设备的分辨率不是常有的,那么此时在系统里的默认的布局文件中获取默认的布局参数。In this embodiment, if there is no parameter matching the resolution of the current display device in the Xml file in which the layout parameters of the resolution of the display device are written, the default target layout parameters are obtained in the preset layout file . Since the current TV monitors, mobile phone screens, or computer screens all have corresponding screen size standards, and several standard resolutions are set correspondingly, so the layout corresponding to several common resolutions is written in the Xml file parameters, but there is no matching resolution in the Xml file, it means that the resolution of the current display device is not common, then at this time, obtain the default layout parameters in the default layout file in the system.
本实施例通过判断当前显示设备的分辨率是否为常见的分辨率,或者说是否存在于Xml文件中来分配不同分辨率的布局参数;如果在Xml文件中没有与之对应的分辨率参数,则在默认的布局文件中获取默认的目标布局参数。以此将显示区分为标准和非标准,统一管理,方便应用。This embodiment assigns layout parameters of different resolutions by judging whether the resolution of the current display device is a common resolution, or whether it exists in the Xml file; if there is no corresponding resolution parameter in the Xml file, then Get the default target layout parameters in the default layout file. In this way, the display is divided into standard and non-standard, unified management, and convenient application.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611270844.3A CN106648700A (en) | 2016-12-29 | 2016-12-29 | Display method and device compatible with different resolution ratios |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201611270844.3A CN106648700A (en) | 2016-12-29 | 2016-12-29 | Display method and device compatible with different resolution ratios |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN106648700A true CN106648700A (en) | 2017-05-10 |
Family
ID=58838422
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201611270844.3A Pending CN106648700A (en) | 2016-12-29 | 2016-12-29 | Display method and device compatible with different resolution ratios |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN106648700A (en) |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107678718A (en) * | 2017-09-19 | 2018-02-09 | 惠州Tcl移动通信有限公司 | Compatibility processing method, mobile terminal and the storage medium of different resolution display screen |
| CN108172200A (en) * | 2018-01-25 | 2018-06-15 | 腾讯科技(深圳)有限公司 | A kind of method and terminal device of this display of applicating Chinese |
| CN112035199A (en) * | 2020-08-13 | 2020-12-04 | 华为技术有限公司 | Interface layout method, electronic device, and computer-readable storage medium |
| CN114020227A (en) * | 2021-10-26 | 2022-02-08 | 瑞芯微电子股份有限公司 | Method for modifying display parameters and being compatible with various display screens and storage device |
| CN114637507A (en) * | 2022-03-29 | 2022-06-17 | 建信融通有限责任公司 | Interface layout adapting method, system, storage medium and electronic equipment |
Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2007141001A (en) * | 2005-11-18 | 2007-06-07 | Sharp Corp | Display device, content display method, content display program, and recording medium |
| CN103345388A (en) * | 2013-06-05 | 2013-10-09 | 中国电子科技集团公司第十五研究所 | Android-operating-system-based system and device for adapting software to mobile terminal |
| CN103593196A (en) * | 2013-11-25 | 2014-02-19 | 深信服网络科技(深圳)有限公司 | Page layout self-adaptation method and device |
| CN103744595A (en) * | 2013-12-30 | 2014-04-23 | 广州华多网络科技有限公司 | Self-adaption display method and configuration file generating method and device |
| CN105282321A (en) * | 2015-08-28 | 2016-01-27 | 上海健保科技有限公司 | Adaption method of application software user interface and display device |
| CN105373385A (en) * | 2015-11-23 | 2016-03-02 | 四川长虹电器股份有限公司 | Multi-resolution UI (User Interface) adaption scripting development method of Android application |
| CN105653254A (en) * | 2014-12-03 | 2016-06-08 | 科大讯飞股份有限公司 | Native interface adaptive method, apparatus and electronic equipment employing same |
| CN105718594A (en) * | 2016-01-29 | 2016-06-29 | 四川长虹电器股份有限公司 | Self-adaptive interface display method for intelligent terminal |
| CN105912350A (en) * | 2015-11-02 | 2016-08-31 | 乐视致新电子科技(天津)有限公司 | Software adaption method and software adaption system compatible to a plurality of screen parameters |
-
2016
- 2016-12-29 CN CN201611270844.3A patent/CN106648700A/en active Pending
Patent Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2007141001A (en) * | 2005-11-18 | 2007-06-07 | Sharp Corp | Display device, content display method, content display program, and recording medium |
| CN103345388A (en) * | 2013-06-05 | 2013-10-09 | 中国电子科技集团公司第十五研究所 | Android-operating-system-based system and device for adapting software to mobile terminal |
| CN103593196A (en) * | 2013-11-25 | 2014-02-19 | 深信服网络科技(深圳)有限公司 | Page layout self-adaptation method and device |
| CN103744595A (en) * | 2013-12-30 | 2014-04-23 | 广州华多网络科技有限公司 | Self-adaption display method and configuration file generating method and device |
| CN105653254A (en) * | 2014-12-03 | 2016-06-08 | 科大讯飞股份有限公司 | Native interface adaptive method, apparatus and electronic equipment employing same |
| CN105282321A (en) * | 2015-08-28 | 2016-01-27 | 上海健保科技有限公司 | Adaption method of application software user interface and display device |
| CN105912350A (en) * | 2015-11-02 | 2016-08-31 | 乐视致新电子科技(天津)有限公司 | Software adaption method and software adaption system compatible to a plurality of screen parameters |
| CN105373385A (en) * | 2015-11-23 | 2016-03-02 | 四川长虹电器股份有限公司 | Multi-resolution UI (User Interface) adaption scripting development method of Android application |
| CN105718594A (en) * | 2016-01-29 | 2016-06-29 | 四川长虹电器股份有限公司 | Self-adaptive interface display method for intelligent terminal |
Non-Patent Citations (1)
| Title |
|---|
| 裂缝中的阳光JDG: "Android自适应不同屏幕几种方法", 《HTTPS://BLOG.CSDN.NET/U012637501/ARTICLE/DETAILS/46619187》 * |
Cited By (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107678718A (en) * | 2017-09-19 | 2018-02-09 | 惠州Tcl移动通信有限公司 | Compatibility processing method, mobile terminal and the storage medium of different resolution display screen |
| CN108172200A (en) * | 2018-01-25 | 2018-06-15 | 腾讯科技(深圳)有限公司 | A kind of method and terminal device of this display of applicating Chinese |
| CN112035199A (en) * | 2020-08-13 | 2020-12-04 | 华为技术有限公司 | Interface layout method, electronic device, and computer-readable storage medium |
| CN114020227A (en) * | 2021-10-26 | 2022-02-08 | 瑞芯微电子股份有限公司 | Method for modifying display parameters and being compatible with various display screens and storage device |
| CN114637507A (en) * | 2022-03-29 | 2022-06-17 | 建信融通有限责任公司 | Interface layout adapting method, system, storage medium and electronic equipment |
| CN114637507B (en) * | 2022-03-29 | 2025-06-17 | 建信融通有限责任公司 | Interface layout adaptation method, system, storage medium and electronic device |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| KR102278932B1 (en) | Application program processing method and terminal device | |
| JP5887419B2 (en) | Method and apparatus for taking a screen shot of an application screen in a mobile terminal | |
| CN106648700A (en) | Display method and device compatible with different resolution ratios | |
| JP5795582B2 (en) | Integrated user interface generation method and apparatus for performing the same | |
| EP3040841A1 (en) | Electronic device and resource display method | |
| CN109101233B (en) | Method for adapting to multiple screen resolutions, storage device and android device | |
| US20100023140A1 (en) | Field device management apparatus and field device management system | |
| WO2020048326A1 (en) | Interface display method and system, and terminal device | |
| US10564913B2 (en) | Display device of multi-display system and control method thereof | |
| CN104714714A (en) | Mobile terminal desktop control method and device and mobile terminal | |
| CN104503722B (en) | The method, device and mobile terminal of compatible display screen | |
| CN104423805A (en) | User terminal apparatus, method for controlling user terminal apparatus, and expanded display system | |
| CN112153459A (en) | Method and device for screen projection | |
| CN110019464B (en) | Page processing method and device | |
| KR20160023394A (en) | display apparatus and control method thereof | |
| CN115396717B (en) | Display device and display image quality adjusting method | |
| CN103856804A (en) | Information processing apparatus, method and system, and output apparatus and method | |
| CN108419114A (en) | A UI interface display method, device and storage medium for smart TV | |
| CN111767492B (en) | Picture loading method and device, computer equipment and storage medium | |
| KR102743249B1 (en) | Electronic device and control method thereof | |
| CN112035108B (en) | User interface layout design method, system, terminal and medium | |
| CN110971958A (en) | Live broadcast gift banner frame-by-frame animation display method, storage medium, equipment and system | |
| CN103686149B (en) | The acquisition methods of browser fault message and system | |
| CN113035154A (en) | Split screen display method, device and system and electronic equipment | |
| CN115934230A (en) | Display adaptation method and device, computer readable storage medium and electronic equipment |
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: 20170510 |
|
| RJ01 | Rejection of invention patent application after publication |