android - Titanium 项目中 android 中的 TableViewRow

标签 android ios appcelerator appcelerator-titanium

我创建了一个 TableView,然后根据需要在其中创建了多个 TableViewRow。 TableViewRow 创建如下:

var row = Ti.UI.createTableViewRow({
    selectBackgoundColor : 'transparent',
    height : '35%'
});

当我在 IOS 中运行我的代码时,它运行完美,但在 Android 中,我需要将“height : '35%'”更改为一个不是 % 的值,如“height : 121”。

为什么“高度:'35%'”在 Android 中不起作用?

最佳答案

Height 35% 在 Android 上不起作用,因为 Android 不知道如何使用 100%。您可以使用多种解决方案。

  1. 根据您知道的父级或设备高度计算 35%。您可以使用它正确计算。

从 deviceHeight 你可以很容易地计算出 35%

var deviceHeight = Ti.Platform.displayCaps.platformHeight;

if (OS_ANDROID){
    deviceHeight = Math.round(Ti.Platform.displayCaps.platformHeight/Ti.Platform.displayCaps.logicalDensityFactor);
}

var thirtyFive = deviceHeight * 0.35;
  1. 使用实际的固定高度。更容易,并且跨应用程序更加一致。

关于android - Titanium 项目中 android 中的 TableViewRow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35465984/

相关文章:

java - Android - 保存/恢复自定义类的状态

ios - 委托(delegate)未调用 Swift 协议(protocol)方法

iphone - iOS : comparing the two images

ios - 将 RxSwift 可观察结果绑定(bind)到另一个可观察结果

javascript - Appcelerator titan - 传递js变量

android-emulator - Titanium 不会运行 iPhone/Android 模拟器

android - 真正的开源跨平台移动开发工具包

android - 在操作栏中移动图像按钮

android - 具有固定卡 ID 的基于主机的卡仿真

Android,使用 parse.com 推送通知,自动启动应用程序