Manuel_Rodrigues
Manuel_Rodrigues

Reputation: 560

TableViewRow in android on Titanium project

I have created a TableView and then e created in a for as many TableViewRow as I need. The TableViewRow is created as folow:

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

When I run my code in IOS it works perfect but in Android I need do change "height : '35%'" to a value that is not in % like "height : 121".

Why does "height : '35%'" not work in Android?

Upvotes: 0

Views: 47

Answers (1)

Rene Pot
Rene Pot

Reputation: 24815

Height 35% doesn't work on Android, because Android doesn't know what to use for the 100%. There are a couple of solutions you could use.

  1. Calculate the 35%, based on the parent you know the height of, or of the device height. You can calculate this properly using this.

From the deviceHeight you can easily calculate 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. Use an actual fixed height. Much easier, and much more consistend across apps.

Upvotes: 4

Related Questions