Roger Daley Well-Known Member Licensed User Longtime User Dec 15, 2019 #1 Hi All A small problem with Edittext alignment. I want the text to be Vertical_Center and Horizontal_Right. Using the designer I always end up with Vertical _Top no matter what the setting.??? In code when I use Gravity.Vertical_Center it is also Horizontal_Left. I can't figure out how to use two gravity parameters in code. Is this possible? [The padding is set to zero.] Regards Roger
Hi All A small problem with Edittext alignment. I want the text to be Vertical_Center and Horizontal_Right. Using the designer I always end up with Vertical _Top no matter what the setting.??? In code when I use Gravity.Vertical_Center it is also Horizontal_Left. I can't figure out how to use two gravity parameters in code. Is this possible? [The padding is set to zero.] Regards Roger
Erel B4X founder Staff member Licensed User Longtime User Dec 15, 2019 #2 I've tried it with the designer and it works properly. Roger Daley said: I can't figure out how to use two gravity parameters in code. Is this possible? Click to expand... Yes. Best option is to use B4XView when you can: Code: Copy Sub Globals Private EditText1 As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") EditText1.SetTextAlignment("CENTER", "RIGHT") End Sub Or: Code: Copy EditText1.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT) Upvote 0
I've tried it with the designer and it works properly. Roger Daley said: I can't figure out how to use two gravity parameters in code. Is this possible? Click to expand... Yes. Best option is to use B4XView when you can: Code: Copy Sub Globals Private EditText1 As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") EditText1.SetTextAlignment("CENTER", "RIGHT") End Sub Or: Code: Copy EditText1.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT)
Roger Daley Well-Known Member Licensed User Longtime User Dec 15, 2019 #3 Erel said: I've tried it with the designer and it works properly. Yes. Best option is to use B4XView when you can: Code: Copy Sub Globals Private EditText1 As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") EditText1.SetTextAlignment("CENTER", "RIGHT") End Sub Or: Code: Copy EditText1.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT) Click to expand... Thanks Erel. The Bit.Or is exactly what I need. Regards Roger Upvote 0
Erel said: I've tried it with the designer and it works properly. Yes. Best option is to use B4XView when you can: Code: Copy Sub Globals Private EditText1 As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") EditText1.SetTextAlignment("CENTER", "RIGHT") End Sub Or: Code: Copy EditText1.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.RIGHT) Click to expand... Thanks Erel. The Bit.Or is exactly what I need. Regards Roger