大佬教程收集整理的这篇文章主要介绍了Android的布局 – 钛处理不同的resoutions,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
//============================================================================= // inch // // compute approximate number of pixels for the specified physical on-screen // size based on the density reported by the OS //============================================================================= function inch(sizE) { // default to 160 dpi if unavailable var height = size * 160.0; try { // compute header height based on screen density ... target .25" height height = size * Ti.Platform.displayCaps.dpi; } catch(E) { warn("Error accessing display caps for screen density calculation: " + E); } return height; }
所以如果你想要的东西是3/4英寸高的屏幕上….
Ti.UI.createThing({ height: inch(.75)});
…或者如果你想通过点大小来扩展事物,可以使一些常量…
const g_12pt = inch(12/72); //0.166667 const g_10pt = inch(10/72); //0.138889 const g_8pt = inch(8/72); //0.111111 const g_6pt = inch(6/72); //0.083333 ... ...font:{fontSize: g_10pt,fontWeight:"bold"},...
我们还创建了几个功能来获得屏幕的高度和宽度,所以如果我们想要在平板电脑上更好的布局或者小的东西,我们可以更好地了解我们正在处理的内容.
//============================================================================= // screenWidth - return screen width in inches //============================================================================= function screenWidth() { return Titanium.Platform.displayCaps.platformWidth / Titanium.Platform.displayCaps.dpi; } //============================================================================= // screenHeight - return screen height in inches //============================================================================= function screenHeight() { return Titanium.Platform.displayCaps.platformHeight / Titanium.Platform.displayCaps.dpi; }
你可以从那里继续下去,但这真的帮助我们了解我们如何在不同的密度和平台上布置我们的屏幕.英寸功能有异常处理,因为我们早在应用程序中使用它,有时候Ti.Platform仍然是未定义的.当我们提供Ti.Platform的报表时,我们提供了这样的功能,所以屏幕功能没有异常处理.如果您需要较早查询,那么您也可能需要异常处理.
希望这可以帮助!
以上是大佬教程为你收集整理的Android的布局 – 钛处理不同的resoutions全部内容,希望文章能够帮你解决Android的布局 – 钛处理不同的resoutions所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。