I have been trying to sort out how to stop a TextView from scrolling within its view by using SizeTofit.
In the process I have set up a simple little test rig:
The weird thing is that when in Portrait the TextView scrolls (which I don't want it to do) BUT when in Landscape the TextView doesn't scroll (which is what I want to happen).
2 questions:
In the process I have set up a simple little test rig:
B4X:
'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#MinVersion: 7
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private TextView1 As TextView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
If TextView1.IsInitialized Then TextView1.RemoveViewFromParent
TextView1.Initialize("")
Page1.RootPanel.AddView(TextView1, 10, 10, Width - 20, Height - 20)
TextView1.SetBorder(1, Colors.Black, 0)
TextView1.Text = "garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage garbage"
TextView1.SizeToFit
End Sub
Private Sub Application_Background
End Sub
The weird thing is that when in Portrait the TextView scrolls (which I don't want it to do) BUT when in Landscape the TextView doesn't scroll (which is what I want to happen).
2 questions:
- Why the difference in behaviour between Portrait and Landscape?
- How can I get scrolling to stop in Portrait?