single line textview in a scrollview


Last Updated:

  1. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
  3. Leolicos

    Leolicos Well-Known Member This Topic's Starter

    Joined:
    Jun 16, 2010
    Messages:
    54
    Likes Received:
    0
    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...