B4J Question Gravity in ComboBox

salman

New Member
hi all
i want set Gravity in ComboBox. i try with under code but dont work for ComboBox.(i know this work for Textfield but i want for ComboBox)

CSSUtils.SetStyleProperty(ComboBox,"-fx-alignment","center-right")
 

inakigarm

Well-Known Member
Licensed User
Longtime User
hi all
i want set Gravity in ComboBox. i try with under code but dont work for ComboBox.(i know this work for Textfield but i want for ComboBox)

CSSUtils.SetStyleProperty(ComboBox,"-fx-alignment","center-right")

Combobox is a more complex node than Textfield ( kind of tableview ). You'll have to create a css file to the project with this info (https://stackoverflow.com/questions/43465201/align-text-in-center-in-combo-box-added-into-table-cell)

Or use https://www.b4x.com/android/forum/threads/customcombobox-class-update-2014-7-12.42691/
 
Upvote 0

salman

New Member
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
Thanks my dear
Before question to ask, I tried with custom combobox. I think this class haven't gravity.
It's not a real combobox; it's made by a Pane with image and label (without selecting state) and a listview in a form (selecting state)
Otherwise, you can change the alignment on this sub, on pos.GetField
B4X:
Private Sub hBoxSetAligment(obj As Object)
    Dim pos As JavaObject
    pos.InitializeStatic("javafx.geometry.Pos")
    pos = pos.GetField("CENTER")
    Dim j As JavaObject = obj
    j.RunMethod("setAlignment", Array(pos))   
End Sub
 
Upvote 0
Top