Hi,
I've got a little problem using scrollview. I'm adding labels to scrollview.panel and after this i want to change the height of the panel according to the number and height of the added labels. But it's not working. When I delete everything from the panel I can change the height easily but is it not possible when it has some views on it?
Thats what I'm trying, but the last command (ScrollViewPlus.Panel.Height = 2000) seems to be ignored, because there is no change in my program. When I change the panel.height at the beginning of the code to 2000 i can scroll more downwards as if I try to change the height at the end of the code.
What am I doing wrong? Does the panel.height not really affect how much I can scroll down? I tried different things and now I have to ask for help.
I bet it's a logical mistake by me... like that with the label.tag. When I click on the added labels in the Scrollview every label has the same number in it's tag, the last number that was in x. But I thought when I initialize the labels in for-to-next this shouldn't happen?! Can anybody help me here to?
thanks in advance
I've got a little problem using scrollview. I'm adding labels to scrollview.panel and after this i want to change the height of the panel according to the number and height of the added labels. But it's not working. When I delete everything from the panel I can change the height easily but is it not possible when it has some views on it?
B4X:
Sub FillScrollViewPlus
Dim label1,label2,label3 As Label
Dim seperator As ImageView
Dim StartHeight As Int
Dim NextEntryPosition As Int
NextEntryPosition = 15
If ScrollViewPlus.Panel.NumberOfViews - 1 > 0 Then
For x = ScrollViewPlus.Panel.NumberOfViews - 1 To 0 Step -1
ScrollViewPlus.Panel.RemoveViewAt(x)
Next
End If
ScrollViewPlus.Panel.Height = 500
Dim i As Int
i = 0
Do While ValueArrayPlus(i,0) <> ""
i = i + 1
Loop
For x = 0 To i - 1
seperator.Initialize("Seperator")
seperator.Bitmap = LoadBitmap(File.DirAssets,"trenner.png")
seperator.Gravity = Gravity.FILL
StartHeight = NextEntryPosition
label1.Initialize("LabelPlusClick")
label2.Initialize("LabelPlusClick")
label3.Initialize("LabelPlusClick")
label1.TextColor = Colors.black
label2.TextColor = Colors.black
label3.TextColor = Colors.RGB(0,150,0)
label1.Text = ValueArrayPlus(x,0)
label2.Text = ValueArrayPlus(x,1)
label3.Text = "+" & ValueArrayPlus(x,2)
label1.TextSize = 10
label2.TextSize = 13
label3.TextSize = 20
label1.Gravity = Gravity.RIGHT
label2.Gravity = Gravity.RIGHT
label3.Gravity = Gravity.RIGHT
label1.Typeface = Typeface.DEFAULT_BOLD
label1.Tag = x
label2.Tag = x
label3.Tag = x
Dim Reflect As Reflector
ScrollViewPlus.Panel.AddView(label1,5,StartHeight,ScrollViewPlus.width-15,-2)
DoEvents
Reflect.Target = label1
ScrollViewPlus.Panel.AddView(label2,5,label1.top+Reflect.RunMethod("getHeight"),ScrollViewPlus.width-15,-2)
DoEvents
Reflect.Target = label2
ScrollViewPlus.Panel.AddView(label3,5,label2.top+Reflect.RunMethod("getHeight"),ScrollViewPlus.width-15,-2)
DoEvents
Reflect.Target = label3
ScrollViewPlus.Panel.AddView(seperator,0,label3.Top+Reflect.RunMethod("getHeight"),ScrollViewPlus.Width,-2)
DoEvents
Reflect.Target = seperator
NextEntryPosition = seperator.top+Reflect.RunMethod("getHeight")
Next
ScrollViewPlus.Panel.Height = 2000
End Sub
Thats what I'm trying, but the last command (ScrollViewPlus.Panel.Height = 2000) seems to be ignored, because there is no change in my program. When I change the panel.height at the beginning of the code to 2000 i can scroll more downwards as if I try to change the height at the end of the code.
What am I doing wrong? Does the panel.height not really affect how much I can scroll down? I tried different things and now I have to ask for help.
I bet it's a logical mistake by me... like that with the label.tag. When I click on the added labels in the Scrollview every label has the same number in it's tag, the last number that was in x. But I thought when I initialize the labels in for-to-next this shouldn't happen?! Can anybody help me here to?
thanks in advance