I know there has been many posts about this but i always get it wrong so i want to ask few questions regarding scrollview.
1. Is it good to add scrollview through a designer or through the code.
2. Incase we are load layout from scrollview.panel.layout() , How to set the scrollview height so that it occupies all the contents in the layout.
I am adding a scrollview to the activity and then loading a layout by calling scrollview.panel.layout() but i am not able to set the height of the scrollview properly when device is in landscape mode.
here is the code
In the layout there is a SettingsMain panel which contain all the labels and buttons mentioned in the code.
I tried to set the scrollview panel height to SettingsMain panel height but it dint work
Kindly let me know the mistake i am making here.
Regards,
SK
1. Is it good to add scrollview through a designer or through the code.
2. Incase we are load layout from scrollview.panel.layout() , How to set the scrollview height so that it occupies all the contents in the layout.
I am adding a scrollview to the activity and then loading a layout by calling scrollview.panel.layout() but i am not able to set the height of the scrollview properly when device is in landscape mode.
here is the code
B4X:
#Region Project Attributes
#ApplicationLabel: FPAC Manager
#VersionCode: 1
#VersionName: Demo
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim WRAP_WIDTH As Int : WRAP_WIDTH = -2
Dim WRAP_HEIGHT As Int : WRAP_HEIGHT = -2
Dim Main_Text_Size As Int : Main_Text_Size = 20
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
'Settings Layout Variables
Dim ActivityLabel As Label
Dim ActivitySpinner As Spinner
Dim CriticalButton As Switch
Dim CriticalLabel As Label
Dim DividerPanel As Panel
Dim EquipLabel As Label
Dim EquipSpinner As Spinner
Dim HighRButton As RadioButton
Dim LowRButton As RadioButton
Dim MainModeLabel As Label
Dim MedRButton As RadioButton
Dim ProjectLabel As Label
Dim ProjectSpinner As Spinner
Dim PunchListButton As Switch
Dim PunchListLabel As Label
Dim RiskLabel As Label
Dim SafetyButton As Switch
Dim SafetyLabel As Label
Dim SettingsMain As Panel
Dim MainModButton As Switch
Dim MainScrollView As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
MainScrollView.Initialize(1000dip)
Activity.AddView(MainScrollView,0,0,100%x,100%y)
MainScrollView.Panel.LoadLayout("Settings")
Set_Text
Resize_Labels
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Set_Text
ActivityLabel.Text = "Activity"
ActivityLabel.TextSize = Main_Text_Size
ProjectLabel.Text = "Project"
ProjectLabel.TextSize = Main_Text_Size
EquipLabel.Text = "Equip."
EquipLabel.TextSize = Main_Text_Size
MainModeLabel.Text = "Maintainence Mode"
MainModeLabel.TextSize = Main_Text_Size
SafetyLabel.Text = "Safety Complaince"
SafetyLabel.TextSize = Main_Text_Size
PunchListLabel.Text = "Punch List Inclusion"
PunchListLabel.TextSize = Main_Text_Size
CriticalLabel.Text = "Critical Condition"
CriticalLabel.TextSize = Main_Text_Size
RiskLabel.Text = "Risk"
RiskLabel.TextSize = Main_Text_Size
LowRButton.Text = "Low"
LowRButton.TextSize = Main_Text_Size
MedRButton.Text = "Med"
MedRButton.TextSize = Main_Text_Size
HighRButton.Text = "High"
HighRButton.TextSize = Main_Text_Size
End Sub
Sub Resize_Labels
ActivityLabel.Width = WRAP_WIDTH
ActivityLabel.Height = WRAP_HEIGHT
ProjectLabel.Width = WRAP_WIDTH
ProjectLabel.Height = WRAP_HEIGHT
EquipLabel.Width = WRAP_WIDTH
EquipLabel.Height = WRAP_HEIGHT
MainModeLabel.Width = WRAP_WIDTH
MainModeLabel.Height = WRAP_HEIGHT
SafetyLabel.Width = WRAP_WIDTH
SafetyLabel.Height = WRAP_HEIGHT
PunchListLabel.Width = WRAP_WIDTH
PunchListLabel.Height = WRAP_HEIGHT
CriticalLabel.Width = WRAP_WIDTH
CriticalLabel.Height = WRAP_HEIGHT
RiskLabel.Width = WRAP_WIDTH
RiskLabel.Height = WRAP_HEIGHT
LowRButton.Width = WRAP_WIDTH
LowRButton.Height = WRAP_HEIGHT
MedRButton.Width = WRAP_WIDTH
MedRButton.Height = WRAP_HEIGHT
HighRButton.Width = WRAP_WIDTH
HighRButton.Height = WRAP_HEIGHT
End Sub
In the layout there is a SettingsMain panel which contain all the labels and buttons mentioned in the code.
I tried to set the scrollview panel height to SettingsMain panel height but it dint work
B4X:
MainScrollView.Panel.Height = SettingsMain.Height
Kindly let me know the mistake i am making here.
Regards,
SK