Hello,
I try to port my project from b4a to b4i but I encounter too many difficulties.
I am confused about: Handle Resize Event - SizeToFit - AutoScaleAll
I use a ViewPager where inside i load a listview per page. Each listview (PCLV + CLVSwipe) has it's own item's layout where in b4a i measured the height by creating dummy labels and loading texts (same as layout's labels):
In clvWorkouts_VisibleRangeChanged i load data:
The result is this:
The first two loaded workouts are pretty well measured but the third one has abnormal height.
If pull to refresh current workouts then every height is abnormal:
Mainpage layout (ViewPager): Handle Resize is checked and AutoscaleAll
Workouts layout (CLV): Handle Resize is checked and AutoscaleAll is off
clvWorkouts layout (item layout):Handle Resize unchecked and AutoscaleAll is off
At first load, item's height:
after pull to refresh:
I have searched every post containing SizeToFit, Handle Resize Event, AutoScaleAll with no luck.
I try to port my project from b4a to b4i but I encounter too many difficulties.
I am confused about: Handle Resize Event - SizeToFit - AutoScaleAll
I use a ViewPager where inside i load a listview per page. Each listview (PCLV + CLVSwipe) has it's own item's layout where in b4a i measured the height by creating dummy labels and loading texts (same as layout's labels):
B4X:
cs.Initialize.Font(Font.DEFAULT_BOLD).Append($"${w.duration}' ${typetxt}${CRLF}${CRLF}"$).Pop.Append(w.workout).PopAll
lblWorkoutTextDummy.AttributedText = cs
lblWorkoutTextDummy.SizeToFit
pnlWorkoutDummy.Height=lblWorkoutTextDummy.Top + lblWorkoutTextDummy.Height+pnlButtonsDummy.Height + 40
Log(pnlWorkoutDummy.Height)
PCLVworkout.AddItem(pnlWorkoutDummy.Height,xui.Color_Transparent,workoutSwipe.CreateItemValue(w,Null))
In clvWorkouts_VisibleRangeChanged i load data:
B4X:
Sub clvWorkouts_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLVworkout.VisibleRangeChanged(FirstIndex, LastIndex)
If i<totalRowsWorkouts Then
Private si As SwipeItem = clvWorkouts.GetValue(i)
Dim item As CLVItem = clvWorkouts.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
Dim w As workout = si.Value
'Create the item layout
pnl.LoadLayout("clvWorkout")
pnl.GetView(0).GetView(0).Text=w.title
cs.Initialize.Font(Font.DEFAULT_BOLD).Append($"${w.duration}' ${typetxt}${CRLF}${CRLF}"$).Pop.Append(w.workout).PopAll
pnl.GetView(0).GetView(1).As(Label).AttributedText=cs
' misc.setLblWrapContent(pnl.GetView(0).GetView(1).As(Label),2)
pnl.GetView(0).GetView(1).As(Label).SizeToFit
pnl.GetView(0).Height=pnl.GetView(0).GetView(1).Top + pnl.GetView(0).GetView(1).Height+pnl.GetView(0).GetView(3).Height + 40
pnl.GetView(0).GetView(2).Top = pnl.GetView(0).GetView(1).top + pnl.GetView(0).GetView(1).Height
MediaManager.TrimMediaCache
End If
If LastIndex=clvWorkouts.Size-10 Then
Log(clvWorkouts.Size)
If (DateTime.Now > lastAddItemsTime + DateTime.TicksPerSecond) And (totalRowsWorkouts+totalRowsComments>clvWorkouts.Size) Then
lastAddItemsTime = DateTime.Now
getComments(clvWorkouts.Size-1,DateTime.Date(datePickerWorkouts.SelectedDate))
End If
End If
End Sub
The result is this:
The first two loaded workouts are pretty well measured but the third one has abnormal height.
If pull to refresh current workouts then every height is abnormal:
Mainpage layout (ViewPager): Handle Resize is checked and AutoscaleAll
Workouts layout (CLV): Handle Resize is checked and AutoscaleAll is off
clvWorkouts layout (item layout):Handle Resize unchecked and AutoscaleAll is off
At first load, item's height:
B4X:
360.5
244
528
after pull to refresh:
B4X:
427.5
277
578
I have searched every post containing SizeToFit, Handle Resize Event, AutoScaleAll with no luck.
Last edited: