Android Question How can I rotate the text on a button

rgarnett1955

Active Member
Licensed User
Hi,

I wish to use a button which has a large height, but small width. I wish to rotate the text on the button -90 degrees so that it fits the button i.e. text reads from bottom of button to top.

How can I do this.

I tried using a panel instead of a button, but did not get very far.

I have searched to forum, but have not found the answer.
 

canalrun

Well-Known Member
Licensed User
A few years ago a member posted a library that allowed you to draw rotated text on controls, I believe.

If I remember, the poster was LucaMS.

Barry.

Does the canvas method DrawTextRotated do what you need?
 
Last edited:

LucaMs

Expert
Licensed User
B4X:
Dim ButtonText As String
ButtonText = "Press me"
  
Dim NewButtonText As String
For i = 0 To ButtonText.Length - 1
    NewButtonText = NewButtonText & ButtonText.SubString2(i, i + 1) & CRLF
Next
' Removes last CRLF
NewButtonText = NewButtonText.SubString2(0, NewButtonText.Length - 1)
Button1.Text = NewButtonText
 
Last edited:

LucaMs

Expert
Licensed User
B4X:
SetVertText(Button1, "Press me")
SetVertText(Label1, "Label1")

Sub SetVertText(Vw As Label, Text As String)
   Dim NewText As String
   For i = 0 To Text.Length - 1
     NewText = NewText & Text.SubString2(i, i + 1) & CRLF
   Next
   ' Removes last CRLF
   NewText = NewText.SubString2(0, NewText.Length - 1)
   Vw.Text = NewText
End Sub
 

Informatix

Expert
Licensed User
Hi,

I wish to use a button which has a large height, but small width. I wish to rotate the text on the button -90 degrees so that it fits the button i.e. text reads from bottom of button to top.

How can I do this.

I tried using a panel instead of a button, but did not get very far.

I have searched to forum, but have not found the answer.
You rotate the button with NineOldAndroids.
B4X:
Dim Noavh As noaViewHelper
Noavh.setRotation(Button, -90)
 

Star-Dust

Expert
Licensed User
Try This

B4X:
Dim R As Reflector
R.Target=Button1
'R.RunMethod2("setRotation","90","java.lang.float")
R.RunMethod2("setRotation","270","java.lang.float")
 

rgarnett1955

Active Member
Licensed User
Thanks for your quick response.

I tried the Star-Dust method, but the "Reflector" type is not recognized.
What library is it in? Reflector?
Where can I download Reflector?

rjg
 

Star-Dust

Expert
Licensed User
Last edited:

Star-Dust

Expert
Licensed User
ohh, yes... You are right... As i am using b4a a few years now i was in the thinking it is installed with b4a :)
you think right.
Is installed with b4a.
 
Top