Change height of the Picker.
Im using the picker but I can't figure out how to change the height of the Picker. https://developer.appcelerator.com/apidoc/mobile/1.1/Titanium.UI.createPicker seems to throw an error so I cant see the api's for it.
var picker = Ti.UI.createPicker({
height: 50
});
I tried that but nothing changes, even tho the 'top' property works fine.. someone help please!
12 Answers
-
I was experimenting to get this to work, and found a way to get the picker to resize. The following transform trick works.
var transformPicker = Titanium.UI.create2DMatrix().scale(0.5); var picker = Ti.UI.createPicker({ backgroundColor: '#ff9900', top: 0, heigth: 10, width: 80, transform:transformPicker });
-
Try to wrap it in a view with a fixed height.
-
Found it!
Heavy workaround but gets the result!var view = Titanium.UI.createView({ height:'auto', width:'auto', right:pWidth*__0.2__ }) var rightSize = false; var i = 0.1; while(!rightSize){ pWidth/i<=__300__ ? rightSize = true : i=i+0.01; } var transformPicker = Titanium.UI.create2DMatrix().scale(i); var picker = Titanium.UI.createPicker({ top:pHeight*0.25, useSpinner:true, type:Titanium.UI.PICKER_TYPE_TIME, value:value, minuteInterval:15, transform:transformPicker }); view.add(picker);
Now you can experiment with the value 300 in line 10. To me 300 is a nice size, but you might want to have you picker bigger, so adjust the 300 to 200 or if you want it smaller you can adjust it to 400 and so forth.
In line 4 you can adjust the value 0.2. If you want the picker to be more left on the screen adjust the 0.2 to 0.3. If you want it more right on the screen adjust 0.2 to 0.1 and so forth.
-
It's not. Not even natively.
-
I was experimenting to get this to work, and found a way to get the picker to resize. The following transform trick works.
var transformPicker = Titanium.UI.create2DMatrix().scale(0.5); var picker = Ti.UI.createPicker({ backgroundColor: '#ff9900', top: 0, heigth: 10, width: 80, transform:transformPicker });
-
Jeff, thanks for the response!
var view = Titanium.UI.createView({ backgroundColor:'red', top: 50, width: 200, height:150 }); view.add(picker); win.add(view);
I tried that. The width seem to work fine but height is not. The picker seem to move out of the view and move toward the top for some reason?
-
is this a bug or is there just no way to do it??
-
I'm having the same problem, any ideas?
-
I would also like to set the height of the picker, and the previous suggestions didn't work for me either. Is there still no way to do this?
-
I'm having the same problem, any ideas?
-
I was experimenting to get this to work, and found a way to get the picker to resize. The following transform trick works.
var transformPicker = Titanium.UI.create2DMatrix().scale(0.5); var picker = Ti.UI.createPicker({ backgroundColor: '#ff9900', top: 0, heigth: 10, width: 80, transform:transformPicker });
-
Found a good workaround if you want the picker to adjust it's size according to the device/displaysize you running the app on.
var rightSize = false; var i = 0.1; while(!rightSize){ pWidth/i<=300 ? rightSize = true : i=i+0.01; } var transformPicker = Titanium.UI.create2DMatrix().scale(i); var picker = Titanium.UI.createPicker({ top:pHeight*0.25, useSpinner:true, type:Titanium.UI.PICKER_TYPE_TIME, value:value, minuteInterval:15, transform:transformPicker });
Now you can experiment with the value 300 in line 4.
To me 300 is a nice size, but you might want to have you picker bigger, so adjust the 300 to 200 or if you want it smaller you can adjust it to 400 and so forth.However I still got the problem that the picker is not centered in the view.