I'm creating a panel for each line received from a web service. Within this panel, I have `BBCodeView1`. Based on the length of the incoming text, I need to calculate the text height, adjust the panel's height accordingly, and then load it onto a `customlistview`.
From examples I found in the forums, I use the following code to calculate the height:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Then, I set the height of my panel using the computed `h` variable with this code:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
However, I'm facing issues (as attached). I know I'm making a mistake somewhere, but I can't figure out what I'm doing wrong. I'd appreciate your assistance.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			From examples I found in the forums, I use the following code to calculate the height:
			
				B4X:
			
		
		
		Dim h As Int = BBCodeView1.Paragraph.Height / Helper.TextEngine.mScale + BBCodeView1.Padding.Top + BBCodeView1.Padding.Bottom
	Then, I set the height of my panel using the computed `h` variable with this code:
			
				B4X:
			
		
		
		PanelInput.AddView(PanelHe, 0, yIndex, PanelBox.Width, h)
yIndex = yIndex + PanelHe.Height
PanelInput.SetLayoutAnimated(0, PanelInput.Left, PanelInput.Top, PanelInput.Width, PanelHe.top + PanelHe.Height + 2dip)
PanelBox.SetLayoutAnimated(0, PanelBox.Left, PanelBox.Top, PanelBox.Width, PanelHe.top + PanelHe.Height + 2dip)
	However, I'm facing issues (as attached). I know I'm making a mistake somewhere, but I can't figure out what I'm doing wrong. I'd appreciate your assistance.
			
				B4X:
			
		
		
		If Rel_Users_Expertises.Size >0  Then
        Dim PanelTitle As B4XView = xui.CreatePanel("PanelTitle")
       PanelTitle.SetLayoutAnimated(0,0,0,lstvForm.AsView.Width*0.9,GetDeviceLayoutValues.Height*0.07)
       lstvForm.Add(PanelTitle,"")
       Dim lbl As Label
       lbl.Initialize("")
       PanelTitle.AddView(lbl,lstvForm.AsView.Width*0.05,0,PanelTitle.Width,PanelTitle.Height)
       lbl.Color= Colors.Transparent
        Helper.ChangeTitle("Expertises",Colors.Black,20,lbl, "ALIGN_LEFT", Helper.FontBold,"0xF5B0","2")
        Dim PanelBox As B4XView = xui.CreatePanel("PanelAction")
        PanelBox.SetLayoutAnimated(0,0,0,lstvForm.AsView.Width*0.9, (GetDeviceLayoutValues.Height*0.1)  )
        Dim PanelInput As B4XView = xui.CreatePanel("")
        PanelInput.SetColorAndBorder(Colors.White,1dip, 0xFFE6E6E6,PanelBox.Height*0.01)
        PanelBox.AddView(PanelInput,lstvForm.AsView.Width*0.05,0,lstvForm.AsView.Width*0.9,PanelBox.Height)
        Dim y As Int=0
        Dim yIndex As Int=0
'####### panel inside BBCodeView1 for each line
        For Each colRel_Users_Expertises As Map In Rel_Users_Expertises
            Dim xx As String ="[Alignment=Left][color=#000000][Font=MyIconFont][/Font][/color][b][Font=MyFont]" & colRel_Users_Expertises.Get("ExpertiseID") & "[/Font][/b]"
            Dim PanelHe As B4XView = xui.CreatePanel("")
            PanelHe.LoadLayout("LayoutBBView")
            BBCodeView1.TextEngine = Helper.TextEngine
            BBCodeView1.sv.Color= Colors.Transparent
            BBCodeView1.Text=xx
            Dim h As Int = BBCodeView1.Paragraph.Height / Helper.TextEngine.mScale + BBCodeView1.Padding.Top + BBCodeView1.Padding.Bottom+10dip
            PanelInput.AddView(PanelHe,0,yIndex ,PanelBox.Width,h)
      PanelHe.Color= Colors.White
            yIndex=yIndex +PanelHe.Height
            PanelInput.SetLayoutAnimated(0,PanelInput.Left,PanelInput.Top,PanelInput.Width,PanelHe.top +PanelHe.Height+2dip)
            PanelBox.SetLayoutAnimated(0,PanelBox.Left,PanelBox.Top,PanelBox.Width,PanelHe.top +PanelHe.Height+2dip)
            y=y+1
            If y>0 Then
                PanelInput.AddView(Helper.AddLine(lstvForm.AsView.Width,Colors.LightGray),0, (PanelHe.Top+PanelHe.Height+1dip),PanelInput.Width,2dip)
                yIndex=yIndex +2dip
            End If
        Next
####### panel inside BBCodeView1 for each line
        lstvForm.Add(PanelBox,"")
    End If