Diceman Active Member Licensed User Mar 31, 2021 #1 I find it annoying when I enter more than 1 line of text in a button or a label and want each line to appear CENTER but they display as CENTER LEFT instead. Is there a workaround for this? Or am I missing something? I wrote a small app to demonstrate this. The output is shown below. Each of the 3 views have the text CENTER aligned, but they are really appear to be CENTER LEFT aligned whenever there is more than 1 text displayed in the view. Attachments TestButtonCenter.zip TestButtonCenter.zip 3.1 KB · Views: 418
I find it annoying when I enter more than 1 line of text in a button or a label and want each line to appear CENTER but they display as CENTER LEFT instead. Is there a workaround for this? Or am I missing something? I wrote a small app to demonstrate this. The output is shown below. Each of the 3 views have the text CENTER aligned, but they are really appear to be CENTER LEFT aligned whenever there is more than 1 text displayed in the view.
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #2 CSS can help you: Sample: Last edited: Mar 31, 2021 Upvote 0
Diceman Active Member Licensed User Mar 31, 2021 #3 Thanks for the reply. Is this CSS solution of yours cross-platform compatible? I noticed your example with the yellow buttons are still left justified. Do you know what the CSS command is to center the text? This is what it should look like: TIA Upvote 0
Thanks for the reply. Is this CSS solution of yours cross-platform compatible? I noticed your example with the yellow buttons are still left justified. Do you know what the CSS command is to center the text? This is what it should look like: TIA
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #4 test: -fx-alignment: center ; Click to expand... Upvote 0
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #6 Is this CSS solution of yours cross-platform compatible? Click to expand... No this use JavaFX CSS JavaFX CSS Reference Guide This document describes the JavaFX Cascading Style Sheets (CSS) for JavaFX 8 and explains the styles, values, properties and associated grammar. docs.oracle.com text: JavaFX CSS Reference Guide This document describes the JavaFX Cascading Style Sheets (CSS) for JavaFX 8 and explains the styles, values, properties and associated grammar. docs.oracle.com Upvote 0
Is this CSS solution of yours cross-platform compatible? Click to expand... No this use JavaFX CSS JavaFX CSS Reference Guide This document describes the JavaFX Cascading Style Sheets (CSS) for JavaFX 8 and explains the styles, values, properties and associated grammar. docs.oracle.com text: JavaFX CSS Reference Guide This document describes the JavaFX Cascading Style Sheets (CSS) for JavaFX 8 and explains the styles, values, properties and associated grammar. docs.oracle.com
Diceman Active Member Licensed User Mar 31, 2021 #7 Unfortunately it has to work on B4J, B4A and B4i. ? I would have thought the Alignment property set to CENTER would have handled multiple lines properly. It looks like I will have to eliminate views displaying more than 1 line of text if I want the text centered properly. Upvote 0
Unfortunately it has to work on B4J, B4A and B4i. ? I would have thought the Alignment property set to CENTER would have handled multiple lines properly. It looks like I will have to eliminate views displaying more than 1 line of text if I want the text centered properly.
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #9 Diceman said: Unfortunately it has to work on B4J, B4A and B4i. ? I would have thought the Alignment property set to CENTER would have handled multiple lines properly. It looks like I will have to eliminate views displaying more than 1 line of text if I want the text centered properly. Click to expand... if you want cross-platform, you can do it by code using B4Xview Upvote 0
Diceman said: Unfortunately it has to work on B4J, B4A and B4i. ? I would have thought the Alignment property set to CENTER would have handled multiple lines properly. It looks like I will have to eliminate views displaying more than 1 line of text if I want the text centered properly. Click to expand... if you want cross-platform, you can do it by code using B4Xview
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #10 SAMPLE: Dim mTextView As B4XView mTextView = CreateLabel("") mTextView.SetTextAlignment("CENTER","CENTER") Click to expand... Private Sub CreateLabel(Event As String) As B4XView Dim Lbl As Label Lbl.Initialize(Event) Return Lbl End Sub Click to expand... Upvote 0
SAMPLE: Dim mTextView As B4XView mTextView = CreateLabel("") mTextView.SetTextAlignment("CENTER","CENTER") Click to expand... Private Sub CreateLabel(Event As String) As B4XView Dim Lbl As Label Lbl.Initialize(Event) Return Lbl End Sub Click to expand...
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #11 see B4J Dim jo As JavaObject = Label3 jo.RunMethod("setTextAlignment", Array("CENTER")) Click to expand... Upvote 0
see B4J Dim jo As JavaObject = Label3 jo.RunMethod("setTextAlignment", Array("CENTER")) Click to expand...
TILogistic Expert Licensed User Longtime User Mar 31, 2021 #12 search in forum: Search Results | B4X Programming Forum Upvote 0
Diceman Active Member Licensed User Apr 1, 2021 #13 Thanks for the feedback. I am trying your examples to see how it works. I also think CharSequence may be the answer. I will have to play with Alignment("ALIGN_CENTER") tomorrow. Upvote 0
Thanks for the feedback. I am trying your examples to see how it works. I also think CharSequence may be the answer. I will have to play with Alignment("ALIGN_CENTER") tomorrow.
Erel B4X founder Staff member Licensed User Longtime User Apr 1, 2021 #14 Check BBLabel or BBCodeView Upvote 0