Android Question Rotate a textview

Sagenut

Expert
Licensed User
Longtime User
You can include it inside a panel.
Rotating the panel will rotate even the view contained in it.
Probably it will be enough to declare it as a B4XView and then you should have the Rotation method.
The panel trick can be useful if you need to rotate a group of view all together.
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Label1 As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Label1.Rotation = 45
End Sub
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would suggest you to use the code in post #1.
But you could use this alternative:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Label1.As(B4XView).Rotation = 45
End Sub
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
You should always prefer the @Sagenut version, i.e. declare the Label as B4XView and, if necessary, use the AS function to temporarily convert to the native View (Label in this case), not viceversa.

Actually, right now, I have tested a B4XPanel and laid a TextEdit onto it. Rotating works perfectly.

Thank you.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Actually, right now, I have tested a B4XPanel and laid a TextEdit onto it. Rotating works perfectly.

Thank you.
I spoke in general. It would be a good habit to declare all the views as B4XView, therefore also that TextEdit (and, when nedeed, use TextEdit specific properties "via" the AS function; this because B4XView cannot have all properties of all native views).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…