I Ilya G. Active Member Licensed User Longtime User Jul 18, 2021 #1 Please tell me how to place selected item in the middle of screen? I already broke my brain
aeric Expert Licensed User Longtime User Jul 18, 2021 #2 Have you tried ScrollToItem or JumpToItem ? Upvote 0
I Ilya G. Active Member Licensed User Longtime User Jul 18, 2021 #3 aeric said: Have you tried ScrollToItem or JumpToItem ? Click to expand... It place selected item at the left border Upvote 0
aeric said: Have you tried ScrollToItem or JumpToItem ? Click to expand... It place selected item at the left border
aeric Expert Licensed User Longtime User Jul 19, 2021 #4 GanjaKyp said: It place selected item at the left border View attachment 116630 Click to expand... Then you plus or minus 2 index. Upvote 0
GanjaKyp said: It place selected item at the left border View attachment 116630 Click to expand... Then you plus or minus 2 index.
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #5 But if the screen is narrow and only 4 elements are visible, how to show the selected one exactly in the center? Upvote 0
But if the screen is narrow and only 4 elements are visible, how to show the selected one exactly in the center?
William Lancee Well-Known Member Licensed User Longtime User Jul 19, 2021 #6 Are all five circular elements in one panel? In a list of panels? If so it is more complicated but doable, let us know. Upvote 0
Are all five circular elements in one panel? In a list of panels? If so it is more complicated but doable, let us know.
William Lancee Well-Known Member Licensed User Longtime User Jul 19, 2021 #8 What I mean is are there five parts to each panel? How do define them? Or is it a horizontal CLV? Upvote 0
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #9 Each panel consists of two elements Upvote 0
William Lancee Well-Known Member Licensed User Longtime User Jul 19, 2021 #10 So it is a horizontal CLV. Now what is your question? How to scroll to the selected item and then make sure it is in the center of the screen? Upvote 0
So it is a horizontal CLV. Now what is your question? How to scroll to the selected item and then make sure it is in the center of the screen?
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #11 Yes, sorry my english is poor)) Upvote 0
William Lancee Well-Known Member Licensed User Longtime User Jul 19, 2021 #12 That is ok. As @aeric pointed out you can simply scroll to the selected item with an adjustment based on screen size. In other words, in CustomListView1_ItemClick, CustomListView1.JumpToItem (index + adjustmentForScreenwidth). Upvote 0
That is ok. As @aeric pointed out you can simply scroll to the selected item with an adjustment based on screen size. In other words, in CustomListView1_ItemClick, CustomListView1.JumpToItem (index + adjustmentForScreenwidth).
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #13 I understand that, but how to place it exactly in the middle? Upvote 0
William Lancee Well-Known Member Licensed User Longtime User Jul 19, 2021 #14 In B4Xpages center of screen is Root.width / 2 In standard android apps it is Activity.Width / 2 leftMarginTarget = the center of screen minus the panel width / 2 The underlying scrollView is found in CustomlistView1.sv CustomListView1.JumpToItem (index) CustomListView1.sv.ScrollViewOffsetX = CustomListView1.sv.ScrollViewOffsetX - leftMarginTarget Let me know if this works. Edit. If you looked at this a few minutes ago, I changed the + sign to a - sign Last edited: Jul 19, 2021 Upvote 0
In B4Xpages center of screen is Root.width / 2 In standard android apps it is Activity.Width / 2 leftMarginTarget = the center of screen minus the panel width / 2 The underlying scrollView is found in CustomlistView1.sv CustomListView1.JumpToItem (index) CustomListView1.sv.ScrollViewOffsetX = CustomListView1.sv.ScrollViewOffsetX - leftMarginTarget Let me know if this works. Edit. If you looked at this a few minutes ago, I changed the + sign to a - sign
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #15 It doesn't seem to work B4X: clv.JumpToItem(index) clv.sv.ScrollViewOffsetX = clv.sv.ScrollViewOffsetX + ((clv.AsView.Width / 2) - (clv.GetPanel(index).Width / 2)) Upvote 0
It doesn't seem to work B4X: clv.JumpToItem(index) clv.sv.ScrollViewOffsetX = clv.sv.ScrollViewOffsetX + ((clv.AsView.Width / 2) - (clv.GetPanel(index).Width / 2))
Erel B4X founder Staff member Licensed User Longtime User Jul 19, 2021 #16 1. Remove the call to JumpToItem. 2. B4X: Dim item As CLVItem = clv.GetRawListItem(index) clv.sv.ScrollViewOffsetX = item.Offset + clv.AsView.Width / 2 - item.Size Upvote 0
1. Remove the call to JumpToItem. 2. B4X: Dim item As CLVItem = clv.GetRawListItem(index) clv.sv.ScrollViewOffsetX = item.Offset + clv.AsView.Width / 2 - item.Size
I Ilya G. Active Member Licensed User Longtime User Jul 19, 2021 #17 B4X: Dim x As XUI, p As B4XView = x.CreatePanel("") p.Width = 100dip p.Height = 100dip p.LoadLayout("category_2") clv.Add(p, 0) then check B4X: Dim item As CLVItem = clv.GetRawListItem(index) Log(DipToCurrent(100dip) & " / " & item.Size) and get 225 /150, why is this happening? Upvote 0
B4X: Dim x As XUI, p As B4XView = x.CreatePanel("") p.Width = 100dip p.Height = 100dip p.LoadLayout("category_2") clv.Add(p, 0) then check B4X: Dim item As CLVItem = clv.GetRawListItem(index) Log(DipToCurrent(100dip) & " / " & item.Size) and get 225 /150, why is this happening?
Erel B4X founder Staff member Licensed User Longtime User Jul 19, 2021 #18 This is a mistake: B4X: DipToCurrent(100dip) It should be: B4X: Log(100dip & " / " & item.Size) 'or Log(DipToCurrent(100) & " / " & item.Size) Upvote 0
This is a mistake: B4X: DipToCurrent(100dip) It should be: B4X: Log(100dip & " / " & item.Size) 'or Log(DipToCurrent(100) & " / " & item.Size)