Hi,
I have a problem with a scrollView. The app has more pages, and when I load the one with a scrollView the first time, everything's all right.
If I go back, and then load it again, it basically loads the same layout twice, so I have all views doubled. Like this, to be clear:
Also, each time I go back and reload the scrollView, the dimensions of the views inside of it get bigger.
To manage the page, I made another code module, and this is its code:
What am I doing wrong? How can I solve this problem?
Let me know if I have to provide more information.
I have a problem with a scrollView. The app has more pages, and when I load the one with a scrollView the first time, everything's all right.
If I go back, and then load it again, it basically loads the same layout twice, so I have all views doubled. Like this, to be clear:
Also, each time I go back and reload the scrollView, the dimensions of the views inside of it get bigger.
To manage the page, I made another code module, and this is its code:
B4X:
'Code module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Private pg As Page
Private Dialog As B4XDialog
Private XUI As XUI
Private Base As B4XView
Private DateTemplate As B4XDateTemplate
Private hd As HUD
Private btnData As Button
Private btnDonna As Button
Private btnRegistrati As Button
Private btnUomo As Button
Private chkDati As Button
Private chkTermini As Button
Private lblDati As Label
Private lblDatiAccesso As Label
Private lblTermini As Label
Private Panel1 As Panel
Private txtCap As TextField
Private txtCitta As TextField
Private txtConfirm As TextField
Private txtEmail As TextField
Private txtIndirizzo As TextField
Private txtPassword As TextField
Private txtProvincia As TextField
Private txtUser As TextField
Private backgroundImage As ImageView
Private logoImage As ImageView
Private ScrollView1 As ScrollView
Dim sesso As String = "N"
Dim data As String = ""
Dim check As Int = 0
Dim checkdati As Int = 0
Dim myImage As Bitmap
Dim pref() As Int = Array As Int(0, 0, 0, 0, 0, 0, 0, 0)
Private btnOk As Button
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
Private Button4 As Button
Private Button5 As Button
Private Button6 As Button
Private Button7 As Button
Private Button8 As Button
Private Label1 As Label
Private Label2 As Label
Private Label3 As Label
Private Label4 As Label
Private Label5 As Label
Private Label6 As Label
Private Label7 As Label
Private Label8 As Label
Private lblCategoria As Label
Private lblSeleziona As Label
Private panelPreferenze As Panel
End Sub
Public Sub Show
If pg.IsInitialized = False Then
pg.Initialize("pg")
pg.RootPanel.LoadLayout("Scroll")
End If
Main.NavControl.ShowPage(pg)
ScrollView1.Panel.LoadLayout("Register")
setScrollViewSize(ScrollView1, Panel1.Width, Panel1.Height, False)
SetButtonAlignment(btnData, 1)
hintcolor
Base = pg.RootPanel
Dialog.Initialize (Base)
DateTemplate.Initialize
coloritemplate
End Sub
Private Sub pg_Resize(Width As Int, Height As Int)
ScrollView1.ContentWidth = Width
End Sub
Sub SetHintColor(tf As TextField, clr As Int)
Dim no As NativeObject = tf
Dim attr As AttributedString
attr.Initialize(tf.HintText, tf.Font, clr)
no.SetField("attributedPlaceholder", attr)
End Sub
Sub hintcolor
SetHintColor(txtUser, Colors.RGB(192, 190, 190))
SetHintColor(txtEmail, Colors.RGB(192, 190, 190))
SetHintColor(txtPassword, Colors.RGB(192, 190, 190))
SetHintColor(txtConfirm, Colors.RGB(192, 190, 190))
SetHintColor(txtCap, Colors.RGB(192, 190, 190))
SetHintColor(txtCitta, Colors.RGB(192, 190, 190))
SetHintColor(txtProvincia, Colors.RGB(192, 190, 190))
SetHintColor(txtIndirizzo, Colors.RGB(192, 190, 190))
End Sub
Public Sub setScrollViewSize (scrollViewInstance As ScrollView, floatWidth As Float, floatHeight As Float, booleanBounces As Boolean)
scrollViewInstance.Panel.Width = floatWidth
scrollViewInstance.Panel.Height = floatHeight
scrollViewInstance.ContentWidth = scrollViewInstance.Panel.Width
scrollViewInstance.ContentHeight = scrollViewInstance.Panel.Height
scrollViewInstance.Bounces = booleanBounces
scrollViewInstance.ScrollTo (0, 0, False)
End Sub
Sub SetButtonAlignment(btn As Button, alignment As Int)
Dim no As NativeObject = btn
no.SetField("contentHorizontalAlignment", alignment)
End Sub
Sub SetBackgroundImage(b As Button, bmp As Bitmap, state As Int)
Dim no As NativeObject = b
no.RunMethod("setBackgroundImage:forState:", Array(bmp, state))
End Sub
Sub coloritemplate
Dialog.Title = "Data di nascita"
Dialog.TitleBarColor = Colors.RGB(228, 49, 49)
DateTemplate.MinYear = 1940
DateTemplate.MaxYear = DateTime.GetYear(DateTime.Now)
DateTemplate.HighlightedColor = Colors.RGB(228, 49, 49)
DateTemplate.SelectedColor = Colors.RGB(228, 49, 49)
End Sub
What am I doing wrong? How can I solve this problem?
Let me know if I have to provide more information.
Last edited: