• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps single line textview in a scrollview

Leolicos

Member
Jun 16, 2010
54
0
36
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:
	    ScrollView scroll = new ScrollView(this);
	    scroll.setHorizontalScrollBarEnabled(true);
	    scroll.setHorizontalFadingEdgeEnabled(false);
	    scroll.setVerticalScrollBarEnabled(true);
	    scroll.setVerticalFadingEdgeEnabled(false);
	    scroll.setMeasureAllChildren(true);

	    LinearLayout layout = new LinearLayout(this);
            scroll.addView(layout);

	    for ( int i=0 ; i<someList.size() ; ++i )
	    {
	    	TextView tv = new TextView(this);
	    	tv.setHorizontallyScrolling(true);
                tv.setText(someList.get(i)); // may need to scroll horizontally
                layout.addView(tv);
             }

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?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones