`
isiqi
  • 浏览: 16757227 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

android Supporting multiple screen翻译(二)

阅读更多

How Android supports multiple screens

Using the alternative resources framework使用可选资源框架

The platform's support for loading screen size- and density-specific resources at run time is based on the alternative resources framework.

If you want to use size- or density-specific layouts or drawables in your application and you are not familiar with resource qualifiers or how the platform uses them, please read Alternative Resources.

平台支持在运行时加载基于可选资源框架的多屏幕尺寸和特定密度的资源

如果你想要使用尺寸或者特定密度布局或者是可利用的应用程序,如果你不熟悉资源限定符或者是如何在平台上使用它们,请阅读Alternative Resources.

The foundation of Android's support for multiple screens is a set of built-in compatibility features that together manage the rendering of application resources in an appropriate way for the current device screen. The platform handles most of the work of rendering your application, but also gives you two key ways to control how your application is displayed, if you need or want to use them:

Android起初支持多屏幕是在一组嵌入兼容装置同时用合适的方式管理当前装置的屏幕中应用程序资源的呈现

The platform supports a set of resource qualifiers that let you provide size- and density-specific resources, if needed. The qualifiers for size-specific resources are large, normal, and small, and those for density-specific resources are hdpi (high), mdpi (medium), and ldpi (low). The qualifiers correspond to the generalized densities given in Table 1, above.

。该平台支持一组让你提供尺寸和特定密度的资源限定符,如果需要,对特定资源的限定分为largenormalsmall,对特定密度资源的限定分为hdpihigh),mdpi (medium), and ldpi (low),特定密度的限制符在上表1中已给出。

The platform also provides a <supports-screens> manifest element, whose attributes android:largeScreens, android:normalScreens, and android:smallScreens let you specify what generalized screen sizes your application supports. A fourth attribute, android:anyDensity, lets you indicate whether or not your application includes built-in support for multiple densities.

该平台也提供一个manifest元素<supports-screens>,它的属性android:largeScreens, android:normalScreens, android:smallScreens可以让你指定你的应用程序中所支持的屏幕尺寸,第四个属性android:anyDensity可以指明你的程序是否包含对多重密度的嵌入支持。

At run time, the platform provides three types of support to your application, to ensure the best possible display on the current device screen:

当运行的时候,为了确保在当前的设备屏幕上有最佳的呈现,该平台对你的应用程序提供三种类型的支持:

1、 Pre-scaling of resources (such as image assets)

Based on the density of the current screen, the platform automatically loads any size- or density-specific resources from your application and displays them without scaling. If no matching resources are available, the platform loads the default resources and scales them up or down as needed to match the current screen's generalized density. The platform assumes that default resources are designed for proper display at the baseline screen density of "medium" (160), unless they are loaded from a density-specific resource directory.

For example, if the current screen's density is "high", the platform loads resources that are tagged with the qualifier hdpi and uses them without scaling. If no such resources are available, the platform uses the default resources instead, scaling them from the baseline density ("medium") to "high".

For more information about how to create size- and density-specific resources, see Resource qualifiers.

根据当前屏幕的密度,该平台自动从你的应用程序中加载任何尺寸或者特定密度资源,而且不进行缩放的呈现。如果没有可供使用的资源相匹配,该平台会自动将在默认的资源,并且根据所需增大或者缩放它们来匹配当前屏幕资源的广义密度。该平台假设默认资源在medium屏幕密度的底线范围能适当的呈现,除非他们加载一个特定密度的资源目录。

例如,如果当前屏幕的密度为high,该平台加载资源时标记它的限定符为hdpi,并且不用缩放就可以使用它们。如果没有相关的资源,该平台就会用默认的资源代替,从密度的底线medium缩放到high

2Auto-scaling of pixel dimensions and coordinates

If the application states that it does not support different screen densities, the platform auto-scales any absolute pixel coordinates, pixel dimension values, and pixel math used in the application (such as might be used for specifying the width or padding for a view). It does this to ensure that pixel-defined screen elements are displayed at approximately the same physical size as they would be at the baseline density of "medium" (160). The platform handles this scaling transparently to the application and also reports scaled overall pixel dimensions to the application, rather than physical pixel dimensions.

For instance, suppose a given device is using a WVGA high-denisty screen, which is 480x800 and about the same size as a traditional HVGA screen, but it's running an app that states that it does not support multiple densities.

In this case, the system will "lie" to the application when it queries for screen dimensions, and report 320x533.

Then, when the app does drawing operations, such as invalidating the rectangle from (10,10) to (100, 100), the system will likewise automatically transform the coordinates by scaling them the appropriate amount, and actually invalidate the region (15,15) to (150, 150). The same thing happens in the other direction, if the application is running on a lower-density screen, coordinates are scaled down.

For more information, see the android:anyDensity attribute in Manifest attributes for screens support.

如果应用程序的状态显示它并不支持多种屏幕密度,该平台自动在应用程序中缩放任何绝对的像素坐标,像素密度值,以及像素数。(比如可能会指定特定的宽度或者为一个view填充)。这样做是为了,当它们处于medium的底线密度时,确保自定义像素的屏幕元素以近似相同的物理尺寸呈现。该平台会为应用程序处理明显的缩放,而且会把全部的缩放像素规模通知给应用程序,而并不是物理像素尺寸。

例如,假设一个设备使用的是WVGA高密度480*480的屏幕,和相同的尺寸的HVGA屏幕,但是它运行一个app时状态显示它并不支持多重密度。

这种情况下,当它询问页面尺寸时,系统就会对应用程序“撒谎”说报告时320*533

然后,当app做绘图操作时,比如说让矩形从(10,10)到(100,100)变化,同样地,系统将会通过缩放它们到接近的数据来自动改变坐标,实际上,改变反问式从(15,15) (150, 150),其他的方向也会发生相同的事情,如果应用程序运行在一个低密度的屏幕中,坐标会按比例缩放。

Publishing to Small Screen Devices

To ensure the best experience for users on small-screen devices, Android Market only shows applications that explicitly declare support for small screens. If you developed an application on Android 1.5 or earlier and published it on Android Market, you need to test your application on small screens and then upload an updated version that explicitly indicates support for small screens.

为了确保给用户在小屏幕设备中以最佳的体检,android市场唯一展示了改应用程序是明确的支持小屏幕的。如果你在anroid1.5或者是更早的版本上开发,并且把它发布在android market,你需要在小屏幕上测试你的程序,并且在更新的版本上去装载它,以验证它是否支持小屏幕。

3、Compatibility-mode display on larger screen-sizes

If the current screen's size is larger than your application supports, as specified in the supports-screens element, the platform displays the application at the baseline size ("normal") and density ("medium). For screens larger than baseline, the platform displays the application in a baseline-sized portion of the overall screen, against a black background.

如果当前屏幕的大小大于您的应用程序所支持的supports-screens元素中声明的尺寸,该平台会在基线尺寸(normal)和密度(medium)下显示应用程序,对于比基线大的屏幕,平台将会在整个屏幕的部分用基线尺寸来出现,而并不是用黑色背景。

For instance, suppose a given device is using a WVGA medium density screen, classified as a "large" screen, but the application states that it does not support large screens; in this case, the system will again "lie" to the application when it queries for screen dimensions, and report 320x480. Instead of scaling the application, however, the application's 320x480 interface will be placed as a "postage stamp" in the larger 480x800 screen.For more information, see the android:anyDensity attribute in Manifest elements for screens support and the Screen-Compatibility Examples section.

例如,假设一个给定的设备使用的是中密度的WVGA屏幕,作为一个“large”屏幕划分,但应用程序状态显示它不支持large屏幕,在这种情况下,当它查询屏幕尺寸时,系统将再次撒谎,并报告320x480。而不是缩放的应用程序,但是,该应用程序的320*480用户界面将会以“邮票”的方式放置在比较大的480*480的屏幕上。

In general, these compatibility features ensure that all applications, including those written against Android 1.5 and earlier platform versions, can display properly on most devices, especially when the device's screen is at the baseline "normal" size or larger.

一般来说,这些兼容功能确保所有应用程序,包括对android1.5平台或者早期版本,都可以显示在大多数设备,特别是当设备的屏幕在基准是正常尺寸或者是large

However, note that applications written for the baseline screen may need minor adjustments before they display properly on smaller screens such as QVGA. With the reduced screen area of small screens, there may be tradeoffs in design, content, and function that you, as the application developer, need to consider. For more information about how to prepare an existing application for display on small screens, see Strategies for Legacy Applications.

但是请注意,在它在诸如QVGA的小屏幕上合适的显示之前,应用程序对基线屏幕的书写需要一些小调整,随着小屏幕的屏幕面积减少,作为应用程序的开发者,有可能在设计、内容、函数上需要考虑调整,The sections below provide more information how to take advantage of the platform's multiple-screens support.

分享到:
评论

相关推荐

    Android代码-AnySoftKeyboard

    Android (f/w 2.1 , API level 7 ) on screen keyboard for multiple languages.   Sign up to beta-channel here. Beta versions are pushed via Google Play Store. Features All kinds of keyboards: ...

    Android 4.0 Compatibility Definition

    - **Screen Technology**: Compatibility in supporting various screen technologies, including touch capabilities. ##### 7.2 Input Devices Input device compatibility ensures that input devices like ...

    【大数据课设】p105出租车数据可视化分析-大数据-实训大作业.zip

    项目资源包含:可运行源码+数据集+文档 python + numpy, pandas, matplotlib, pyecharts, wordcloud 适用人群:学习不同技术领域的小白或进阶学习者;可作为课程设计、大作业、工程实训或初期项目立项。 数据来源:数据集taxis.csv从网络下载 数据清洗:异常值与缺失值的处理:有一些数据distance(乘车距离)为零而且上下车地点为空,还有些一些数据的payment(支付方式)为空。 数据预处理:将列名更改成中文 标准化与归一化: 数据分析: 数据可视化:

    TypeScript 入门教程

    TypeScript 入门教程

    人脸识别_课堂考勤_OpenCV_服务端系统_1741777828.zip

    人脸识别项目实战

    历届电赛试题及综合测评(真题+模拟题)

    本资源汇总了 历届全国电子设计竞赛(电赛)真题+模拟题,涵盖 电路设计、嵌入式系统、信号处理、自动控制等核心考点,并提供详细解析及综合测评,帮助参赛者高效备赛、查漏补缺、提升实战能力。 适用人群: 适合 准备参加电子设计竞赛的大学生、电赛爱好者、电子信息类相关专业的学生,以及希望提高电子设计和电路分析能力的工程师。 能学到什么: 电赛考察重点:熟悉往届竞赛的命题方向及考核重点。 电路设计与仿真:提升模拟电路、数字电路、单片机等核心技能。 问题分析与解决能力:通过综合测评找到薄弱点并针对性提升。 实战经验:掌握竞赛策略,提高应试效率和设计能力。 阅读建议: 建议先 通读真题,了解题型与解题思路,然后 结合模拟题实战演练,查找不足并通过测评强化练习,逐步提升竞赛能力。

    2024人工智能如何塑造未来产业:AI对各行业组织带来的的变革研究研究报告.pdf

    2024人工智能如何塑造未来产业:AI对各行业组织带来的的变革研究研究报告.pdf

    人脸识别_Golang_SDK_命令行登录_微信小程序应用_1741772240.zip

    人脸识别项目源码实战

    Vulkan原理与实战课程

    给大家分享一套课程——Vulkan原理与实战课程

    SiriYXR_Sokoban11_1741860914.zip

    c语言学习

    海豚鲸鱼数据集 5435张图 正确识别率可达92.6% 可识别:海豚 虎鲸 蜥蜴 海豹 鲨鱼 龟 支持yolov8格式标注

    海豚鲸鱼数据集 5435张图 正确识别率可达92.6% 可识别:海豚 虎鲸 蜥蜴 海豹 鲨鱼 龟 支持yolov8格式标注

    答谢中书书教学设计.docx

    答谢中书书教学设计.docx

    人脸识别_环境搭建_dlib_face_recognitio_1741771308.zip

    人脸识别项目源码实战

    网络技术_Web服务器_C语言_学习交流版_1741863251.zip

    c语言学习

    安卓开发_Gradle配置_React_Native_Meg_1741777287.zip

    人脸识别项目源码实战

    人工智能_深度学习_图像识别_UI界面_项目展示.zip

    人脸识别项目实战

    基于Springboot框架的美发门店管理系统的设计与实现(Java项目编程实战+完整源码+毕设文档+sql文件+学习练手好项目).zip

    本美发门店管理系统有管理员和用户两个角色。用户功能有项目预定管理,产品购买管理,会员充值管理,余额查询管理。管理员功能有个人中心,用户管理,美容项目管理,项目类型管理,项目预定管理,产品库存管理,产品购买管理,产品入库管理,会员卡管理,会员充值管理,余额查询管理,产品类型管理,系统管理等。因而具有一定的实用性。 本站是一个B/S模式系统,采用SSM框架,MYSQL数据库设计开发,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得美发门店管理系统管理工作系统化、规范化。本系统的使用使管理人员从繁重的工作中解脱出来,实现无纸化办公,能够有效的提高美发门店管理系统管理效率。 关键词:美发门店管理系统;SSM框架;MYSQL数据库;Spring Boot 1系统概述 1 1.1 研究背景 1 1.2研究目的 1 1.3系统设计思想 1 2相关技术 2 2.1 MYSQL数据库 2 2.2 B/S结构 3 2.3 Spring Boot框架简介 4 3系统分析 4 3.1可行性分析 4 3.1.1技术可行性 4 3.1.2经济可行性 5 3.1.3操作可行性 5 3.2系

    Python实现基于SSA-CNN-GRU麻雀算法优化卷积门控循环单元数据分类预测的详细项目实例(含完整的程序,GUI设计和代码详解)

    内容概要:本文档介绍了基于SSA-CNN-GRU麻雀算法优化卷积门控循环单元数据分类预测的详细项目实例,重点讲述了该项目的背景、目标、挑战与解决方案、技术特点、应用领域等方面的内容。文档详细记录了从项目启动、数据预处理、算法设计(SSA优化CNN-GRU模型)、构建与评估模型到实现美观的GUI界面整个过程,并讨论了防止过拟合的技术如正则化、早停和超参数优化。另外还涵盖了项目扩展的可能性、部署和应用策略、需要注意的地方以及未来改进的方向。全文强调了模型的泛化能力和计算效率,展示了该混合算法模型在实际应用中的优越性能。 适合人群:具备一定的Python编程经验及机器学习基础知识的研究人员和技术人员;对深度学习、智能优化算法及实际应用感兴趣的学者和从业者;寻求提升数据分析和预测准确性的金融分析师、数据科学家等相关专业人士。 使用场景及目标:本文档非常适合用作学习和参考资料,以掌握如何将SSA、CNN与GRU三种先进技术结合起来进行复杂的分类和预测问题求解。具体应用场景包括但不限于以下几个方面:金融领域——股票价格预测;医疗保健领域——辅助诊断;工业制造——预防性维护;智能家居——个性化服务;以及其他涉及到时序数据分析和多模态数据处理的场合。文档既包含了理论知识又提供了完整的源代码示例,可以帮助读者理解算法原理并通过实践中加深对其的认识。 其他说明:该项目不仅仅是关于算法的设计实现,更是有关于系统的整体架构规划以及工程上的考量,比如环境准备(确保环境洁净、必要包的安装等)、数据准备、GPU配置支持等等。同时文中给出了详细的代码片段,方便开发者理解和复现实验成果。值得注意的是,虽然文中提供了一套通用解决方案,但在真实场景下还需要针对性的调整参数或修改网络结构来达到最好的性能效果。此外,对于追求更高的预测精度或解决更大规模的问题,作者建议进一步探索深度强化学习等高级技术和多任务学习策略,并且考虑使用增量学习让模型能够适应新数据而不必重新训练整个模型。最后提到安全性和隐私保护也是项目实施过程中的重要因素,要妥善保管用户的敏感信息并且做到合法合规地收集和使用数据。

    人脸识别_T形分布_Gabor变换_特征提取_增强鲁棒性_1741777397.zip

    人脸识别项目实战

Global site tag (gtag.js) - Google Analytics