Android Question ScrollView Label height Problem

Tomas Petrus

Active Member
Licensed User
I have ScrollView with Panel and Labels inside. I tested it on 3 devices and on one of them I have problem with scrolling. Panels are added in For Next from MSSQL database. Here is simplified code

B4X:
Sub Globals

 Private Seznam_zakazek_List As ScrollView 'added by designer, so I don't have to add it again to Activity

End Sub


Sub JobDone (Job As HttpJob)

  Dim parser As JSONParser

  Dim response As String

   

  Dim rows As List

     

   If Job.Success = True Then

  Select Job.JobName

      Case "ListOrders"


  response = Job.GetString()

         parser.Initialize(response)

         rows = parser.NextArray

         

         

  Dim Panel0 As Panel

  Panel0.Initialize("")

    Panel0=Seznam_zakazek_List.Panel

 

  For i = 0 To rows.Size - 1

             

           Dim m As Map

           m = rows.Get(i)


 

  Dim Panel1 As Panel

          Panel1.Initialize("")


  Panel0.AddView(Panel1,0,0,98%x,150dip) 'adding 1 record to Panel0

 

  Dim Nadpis1lbl, Nadpis2lbl, Nadpis3lbl, AdrFromLbl, AdrToLb As Label


  Nadpis1lbl.Initialize("")

           Nadpis2lbl.Initialize("")

           Nadpis3lbl.Initialize("") 


  Dim GD,AdrBgr,Panel1Bgr As GradientDrawable

           

           Panel1Bgr.Initialize("TOP_BOTTOM", Array As Int(Colors.Black, Colors.Black))

           GD.Initialize("TOP_BOTTOM", Array As Int(Colors.ARGB(192, 192,192,192), Colors.ARGB(192, 192,192,192)))


           Panel1.Background = Panel1Bgr

           Panel1.Top = Panel1.Top + 5dip

           

           Panel1.AddView(Nadpis1lbl,3dip,3dip, 31.5%x,30dip) 'adding first label

           

           Nadpis1lbl.Text= m.Get("proName")

           Nadpis1lbl.Gravity = Gravity.CENTER

  Nadpis1lbl.Background = GD

           

           Panel1.AddView(Nadpis2lbl,Nadpis1lbl.Width + 6dip,3dip,31.5%x,30dip) 'adding second label next to first

           Nadpis2lbl.Text= m.Get("katName")

           Nadpis2lbl.Gravity = Gravity.CENTER

           

           Nadpis2lbl.Background = GD

           

           Panel1.AddView(Nadpis3lbl,Nadpis2lbl.Width + Nadpis2lbl.Left + 3dip ,3dip,31.5%x,30dip) 'adding 3. label next to 2.

           Nadpis3lbl.Text= "dorucit XY"

           Nadpis3lbl.Gravity = Gravity.CENTER

           

           Nadpis3lbl.Background = GD


  AdrBgr.Initialize("TOP_BOTTOM", Array As Int(Colors.White, Colors.White))

 

  AdrFromLbl.Initialize("")

           Panel1.AddView(AdrFromLbl,3dip,Nadpis1lbl.Height + 5dip,47.5%x,37dip)

           AdrFromLbl.Text=AdrFrom

       

           AdrFromLbl.Background = AdrBgr

           AdrFromLbl.TextColor = Colors.Black

           AdrFromLbl.Gravity = Gravity.CENTER

           

           AdrToLbl.Initialize("")

           Panel1.AddView(AdrToLbl,AdrFromLbl.Width+6dip,Nadpis1lbl.Height + 5dip,47.5%x,37dip)

           AdrToLbl.Text=AdrTo

           

           AdrToLbl.Background = AdrBgr

           AdrToLbl.TextColor = Colors.Black

           AdrToLbl.Gravity = Gravity.CENTER

     

  PanelTop = PanelTop +  AdrFromLbl.Height + Nadpis1lbl.Height + 10dip

           

         Next

 

  Panel0.Height = PanelTop 'set ScrollView height


    End Select

  Else

    Log("Error: " & Job.ErrorMessage)

    ToastMessageShow("Error: " & Job.ErrorMessage, True)

  End If

  Job.Release


End Sub


Scrolling change AdrFromLbl, AdrToLbl height, but Nadpis1lbl (2,3) stay 30dip. Problem is only on Samsung Duos with Android 4.0.4

There is some syntax problem I think. I uploaded screen with and without scroll.

Thanks for answer
 

Attachments

  • screen-without-scroll.png
    screen-without-scroll.png
    20.6 KB · Views: 90
  • screen-with-scroll.png
    screen-with-scroll.png
    17.7 KB · Views: 101
Top