Using the Seekbar with a ScrollView

JaunLukePicard

Member
Licensed User
Longtime User
I have a question regarding the use of the Seekbar. I see that in the examplkes for ScrollView the Seekbar is added to a panel. Does this need to be or can I just place the seekbar on the screen and use it alone with the ScrollView?

If I should use a panel behind the Seekbar can someonet tell me why? Could I just use the seekbar alone?

I want to provide both Hortizontal and Vertical Scrolling.

Thanks for any assistance...:BangHead:
 

klaus

Expert
Licensed User
Longtime User
You can put the seekbar on the Activity !

What ScrollView Example are you speeking of ?

There are two examples in the Beginner's Guide with Seekbars which are directly on the Activity.
But in these two examples there are two means to scroll horizontaly:
- with a panel, by default (dynamic scrolling)
- with a SeekBar (static scrolling), by default the seekbar is set to Visible = False, not shown.
If in these examples you replace skbScroll.Visible = False by skbScroll.Visible = True, you will have the SeekBar.
You just see the Panel behind it but the SeekBar is on the Activity and not on the Panel.
You could remove the scroll panel and remove the code for it to have only the SeekBar. The goal of having two means was to show both possibilities.

Best regards.
 
Upvote 0

JaunLukePicard

Member
Licensed User
Longtime User
Using a Seekbar with a ScrollView

Klaus,

I have read the Beginners Guide and viewed and studied both examples with the ScrollView. For some reason I'm not quite following on how the position of the Seekbar moves the Panels for Header and Detail in the ScrollView.

I have the following variables defined:

Dim ScrollView_StoreList As ScrollView
Dim SeekBar_StoreEditor As SeekBar
Dim Panel_StoreHeader As Panel
Dim Panel_StoreList As Panel
Dim Panel_StoreOptions As Panel
Dim Timer_ScrollView As Timer

The Panel_StoreOptions is a menu on screen that I don't want moved. So the Seekbar is on the Panel_StoreOptions and is visible. I have the normal ScrollView funtionality (Vertical movement working just fine).

I see that there is a ValueChanged event for the Seekbar. I think I want the Seekbar to show its position onscreen at 0 when the Activity starts and as I move the Seekbar position to the right or left I want the Panel_StoreHeader and Panel_StoreList to move accordingly right or left?

Why use a timer?

:sign0013:
 
Upvote 0

ozgureffe

Member
Licensed User
Longtime User
I hope it helps...

B4X:
Sub Process_Globals

End Sub

Sub Globals
   Dim HorizontalScrollView1 As HorizontalScrollView
   Dim ScrollView1 As ScrollView
   Dim SeekBar1 As SeekBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("main")
      
   ScrollView1.Panel.Height = 1000dip
   HorizontalScrollView1.Panel.Width = 1000dip
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
   
   ScrollView1.ScrollPosition = Value * 10
   
End Sub

Sub ScrollView1_ScrollChanged(Position As Int)
   
   HorizontalScrollView1.ScrollPosition = Position
   
End Sub

Sub HorizontalScrollView1_ScrollChanged(Position As Int)
   
   ScrollView1.ScrollPosition = Position

   SeekBar1.Value = Position / 10

End Sub
 

Attachments

  • ScrollViewExample.zip
    6.9 KB · Views: 292
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
With the Seekbar you set the seekbars Position value to the Left properties of the header panel and the scrollView.
B4X:
' somewhere in the code
skbScroll.Max = scvPersons.Width - Activity.Width


Sub skbScroll_ValueChanged (Value As Int, UserChanged As Boolean)
    'Moves the ScrollView horizontally
    pnlHeader.Left = - Value
    scvPersons.Left = - Value
End Sub
The Timer is not needed for the Seekbar. As I already wrote in the previous post there are two systems for the horizontal scrolling. The Seekbar one of the two, the Timer is used for the other one.

Best regards.
 
Upvote 0
Top