0

I'm making a display in android programmatically and I need scrollview horizontally and vertically. Have been work vertically, but still not work horizontally.

here the code :

    ScrollView sv = new ScrollView(this);
    LinearLayout linearLayout = new LinearLayout(this);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(FILL_PARENT, WRAP_CONTENT);
    linearLayout.setLayoutParams(params);
    linearLayout.setOrientation(VERTICAL); 

    linearLayout.addView(tableLayout(count));
    linearLayout.addView(submitButton());
    sv.addView(linearLayout);
    setContentView(sv);

Please help me to make it work horizontally.

Thankyou :)

  • take a look at this question: http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android – Viking Jun 05 '12 at 13:58

2 Answers2

2

Try HorizontalScrollView if you want horizontal scrolling. You cannot do both horizontal and vertical at the same time though, in that case you'll probably have to write a custom view.

MrJre
  • 7,082
  • 7
  • 53
  • 66
1
HorizontalScrollView sv = new HorizontalScrollView(this);
LinearLayout linearLayout = new LinearLayout(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
linearLayout.setLayoutParams(params);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
Zelleriation
  • 2,834
  • 1
  • 23
  • 23