I want to add pictures to a scrollview based on this example from Klaus http://www.b4x.com/android/forum/th...-a-panel-higher-than-the-screen.9539/#content
But the picture stays on top of the scrollview and don't move with it. How can I add a picture via code to a specific Layout, so that the picture is moving with it? Attached is the small code I made to load the picture. I only added the two variables and the Sub "Add_Smiley" as a sample.
But the picture stays on top of the scrollview and don't move with it. How can I add a picture via code to a specific Layout, so that the picture is moving with it? Attached is the small code I made to load the picture. I only added the two variables and the Sub "Add_Smiley" as a sample.
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim scvTest As ScrollView
Dim pnlTest As Panel
Dim SmileyImgView(1, 1) As ImageView
Dim Smiley As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
scvTest.Panel.LoadLayout("ScrollViewLayout")
scvTest.Panel.Height = pnlTest.Height
Add_Smiley
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub edtItem_FocusChanged (HasFocus As Boolean)
Dim Send As EditText
If HasFocus Then
Send = Sender
scvTest.ScrollPosition = Send.Top - 10dip
End If
End Sub
'**************************************************************************************
Sub Add_Smiley
Dim width, offsetX, offsetY As Int
width = GetDeviceLayoutValues.width /2
Smiley = LoadBitmap(File.DirAssets,"smiley.gif")
offsetX = 0'(100%x - width * 3 - 10dip * 2) / 2
offsetY = 0'(100%y - width * 3 - 10dip * 2) / 2
For x = 0 To 0
For y = 0 To 0
Dim s As ImageView
s.Initialize("ImageView") 'All SuggarImgView share the same event sub
's.Color = Colors.Transparent
s.SetBackgroundImage(Smiley)
Activity.AddView(s,offsetX + x * (width), offsetY + y * (width), width, width)
SmileyImgView(x, y) = s 'store a reference to this view
Next
Next
End Sub
'****************************************************************************************