1. Are you ready for the Galaxy S20? Here is everything we know so far!

single line textview in a scrollview

Discussion in 'Android Development' started by Leolicos, Aug 4, 2010.

  1. Leolicos

    Leolicos Member
    Thread Starter

    I have a TextView that's inside a LinearLayout that's inside a ScrollView. In my program I can dynamically change what the text is in the TextView. The problem is, I want to be able to specify when the TextView does a return (via \n), but sometimes the text is too long and needs to be scrolled horizontally; that part isn't work. here's some code

    Code (Text):
    1.  
    2.  
    3.         ScrollView scroll = new ScrollView(this);
    4.         scroll.setHorizontalScrollBarEnabled(true);
    5.         scroll.setHorizontalFadingEdgeEnabled(false);
    6.         scroll.setVerticalScrollBarEnabled(true);
    7.         scroll.setVerticalFadingEdgeEnabled(false);
    8.         scroll.setMeasureAllChildren(true);
    9.  
    10.         LinearLayout layout = new LinearLayout(this);
    11.             scroll.addView(layout);
    12.  
    13.         for ( int i=0 ; i<someList.size() ; ++i )
    14.         {
    15.             TextView tv = new TextView(this);
    16.             tv.setHorizontallyScrolling(true);
    17.                 tv.setText(someList.get(i)); // may need to scroll horizontally
    18.                 layout.addView(tv);
    19.              }
    20.  
    Is there something I need to set maybe in the linearlayout that tells the scrollview that the textviews may be too big so it needs to scroll? or what?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. blundell

    blundell Well-Known Member

  3. Leolicos

    Leolicos Member
    Thread Starter

    Interesting! I'll look into that, but I'm not looking for my TextView to scroll, I'm looking for the whole Layout to scroll, it scrolls vertically correctly, but it doesn't scroll horizontally...
     
Loading...
Similar Threads - single line textview
  1. Laurel23456
    Replies:
    3
    Views:
    941
  2. aparkin
    Replies:
    5
    Views:
    1,343
  3. Nikols
    Replies:
    0
    Views:
    1,073
  4. D Willison
    Replies:
    5
    Views:
    789
  5. Ian R W
    Replies:
    3
    Views:
    3,262
  6. MoodyBlues
    Replies:
    43
    Views:
    2,232
  7. Graham shoe man
    Replies:
    4
    Views:
    1,170
  8. App Update
    Replies:
    0
    Views:
    734
  9. daniel2344
    Replies:
    2
    Views:
    1,396
  10. Samsung
    Replies:
    0
    Views:
    834

Share This Page

Loading...