Reputation: 89
Could anyone help me how can I use correctly the vertscrollbox in an Android application. I have put a vertscrollbox an one tgroupbox and two tlistbox. You can see in the screenshot. When I want to use landscape mode in my application and tap and hold on the tgroupbox the scroll works prety much. But if I tap and hold one of the tlistbox and try to scroll the scrolling does not work.
Here is a Youtube video about this issue
Upvotes: 0
Views: 1228
Reputation: 2287
The vertical scrollbox will only scroll if it's contents are larger (taller) than the Self.ClientHeight at any orientation. Best way to see this is to place a TLayout on the TVertScrollbox. Then set it's height to more than the Self.ClientHeight. Then it will appear to scroll.
To cater for orientation, and to get the scrolling just right and not too much, use the FormResize event handler:
procedure TfrmMain.FormResize(Sender: TObject);
begin
VScrollBox1.Align := TAlignLayout.Client;
Layout4.Align := TAlignLayout.Horizontal; // stays centered left-right
Layout4.Size.Height := 351 + 200; // space for VK here
Layout4.Size.Width := 451; // doesn't matter actually
You'll note from my comment, that my vertical scrollbox allows enough space for the Virtual Keyboard below it (about 200 pixels). So when the VK comes up, the user can scroll the Layout which is on the vertical scroll box, so the first and the last TEdit controls can be in view but not so much that the extra space at the top and bottom comes into view. The Self.ClientHeight does not get smaller when the keyboard shows. Note: It can be very confusing if the layout is too tall. The 351 value above is the minimum size of the Layout4 so that all my TEdits parented to it are visible at once.
So, for example, if the Self.ClientHeight at that orientation is < 551, the layout appears to scroll and the scrollbar shows on the right when you scroll it (if VertScrollBox1.ShowScrollBars := True)
Upvotes: 1