Android Question How can I rotate the text on a button

rgarnett1955

Active Member
Licensed User
Longtime 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
Longtime 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:
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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:
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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
 
Upvote 0

Informatix

Expert
Licensed User
Longtime 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)
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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")
 
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime 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
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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.
 
Upvote 0
Top