how to dynamically set scrollview height?

electronik54

Member
Licensed User
Longtime User
B4X:
situation.Text = "" &Cursor7.GetString("Situation")&" - "&Cursor7.GetString("Severity")
      lblText.Initialize("")
      lblText2.Initialize("")
      FA_SV.Color = Colors.White
      FA_SV.Panel.AddView(lblText, 0, 0 , 100%x, 100%y)
      
      FA_SV.Panel.Height=lblText.Height
      
      FA_sv_detail.Panel.Height = 100%y
      FA_sv_detail.Panel.AddView(lblText2, 0, 0 , 100%x, 150%y)
      lblText.Color = Colors.White
      lblText2.Color = Colors.White
      lblText.TextColor = Colors.Black
      lblText2.TextColor = Colors.Black
      'lblText.Color = Colors.rgb(255, 235, 214)'Colors.RGB(250, 250, 210
      'lblText2.Color = Colors.rgb(255, 235, 214)
      lblText.Text = "" &Cursor7.GetString("Treatment")
      lblText2.Text = "" & info
      ToastMessageShow("getting Info", False)

i need to automatically change the size of above 2 scrollview(FA_sv & FA_sv_detail).
lblText and lblText2 contains variable content. some are very long some are short. what changes do i make in above code to do that?
 

electronik54

Member
Licensed User
Longtime User
I recommend you to use CustomListView. It has an AddText method which automatically sets the correct height for the label and the scrollview.

ScrollView.Panel.Height sets the height of the scrollable panel.

thank you.:)
but that wont work for me. its resource consuming, and i have to show info(not a clickable list)
 
Last edited:
Upvote 0

electronik54

Member
Licensed User
Longtime User
solved!!

Height = StrUtils.MeasureMultilineTextHeight(lblText2, info)
FA_sv_detail.Panel.Height = Height

code
B4X:
situation.Text = "" &Cursor7.GetString("Situation")
      lblText.Initialize("")
      lblText2.Initialize("")
      
      lblText.TextColor = Colors.Black
      lblText2.TextColor = Colors.Black
      
      FA_SV.Color = Colors.White
      FA_SV.Panel.AddView(lblText, 0, 0 , 100%x, 100%y)
      FA_sv_detail.Panel.AddView(lblText2, 0, 0 , 100%x, 100%y)
      
      Height = StrUtils.MeasureMultilineTextHeight(lblText2, info)
      FA_sv_detail.Panel.Height = Height
      
      'lblText.Color = Colors.rgb(255, 235, 214) 'Colors.RGB(250, 250, 210
      'lblText2.Color = Colors.rgb(255, 235, 214)
      lblText.Text = "" &Cursor7.GetString("Treatment")
      lblText2.Text = "" &Cursor7.GetString("Information")
      ToastMessageShow("getting Info", False)
 
Upvote 0
Top