iOS Question ScrollView and SizeToFit

Discussion in 'iOS Questions' started by ciginfo, Jun 2, 2015.

  1. ciginfo

    ciginfo Active Member Licensed User

    Hello,
    I have a page with a Scrollview1 buit with designer, 100%x, 100%y.
    I add with code a texfield into the Scrollview.
    I have to put text into the texfield with variable length.
    I would like to adapt the text height and scrollview depending on the size.
    I easily adapt the height of textfield with SizeToFit function but height of the scrollview remains often too long.
    Code:
    ScrollView1.Panel.AddView(TxtEcran,10dip,0,100%x,2100dip)
    How to have the length of the scrollview1 according to the text size?
    Thank you
     
  2. klaus

    klaus Expert Licensed User

    Try to set ScrollView1.ContentHeight = TxtEcran.Height
     
  3. ciginfo

    ciginfo Active Member Licensed User

    No, "ScrollView1.ContentHeight = TxtEcran.Height" does not work
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. ciginfo

    ciginfo Active Member Licensed User

    Unable to solve my problem, I need help.
    A small program attached file. In this program how to adapt the height of the TextView and height of scrollview to the length of the text put in the textview?
    If anyone can watch and help me.
    thank you a lot
     

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    This exact feature is implemented in CustomListView. Have you tried it?
     
  7. ciginfo

    ciginfo Active Member Licensed User

    No I have not tried because I have not very well understood. Have I to replace TxtEcran by CustomListView or replace all ScrollView by CustomListView and rebuilt my page inside, which is more complicate.
     
  8. narek adonts

    narek adonts Well-Known Member Licensed User

    please find attached the working project.

    You main issue was that you were changing the text after making the size changes functions.

    Narek
     

    Attached Files:

  9. ciginfo

    ciginfo Active Member Licensed User

    Excellent! Finally the solution! Sure I changed the text size After making the size exchange functions. Big mistake.
    Thank you very much.
     
Loading...