single line textview in a scrollview

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

  1. Leolicos

    Leolicos Well-Known Member
    15

    Jun 16, 2010
    54
    0
    15
    Senior Software Engineer
    Chicago, IL
    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?
     

    Advertisement

  2. blundell

    blundell Well-Known Member
    38

    Apr 23, 2010
    125
    17
    38
    Software Engineer
    UK
  3. Leolicos

    Leolicos Well-Known Member
    15

    Jun 16, 2010
    54
    0
    15
    Senior Software Engineer
    Chicago, IL
    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...
     

Share This Page

Loading...