0

I want to Scroll linear layout (created in java file using LinearLayout layout = new LinearLayout(this)) vertically and also horizontally. ScrollView allows only vertical scrolling HorizontalScrollView allows only horizontal scrolling, But I want both functionality to my LinearLayout.

I haven't got any solution for my question. Many people saying that we can get two dimensional scrolling my embedding HorizontalScrollView inside ScrollView, But this is not giving a good scrolling effect. How ever many sources tells that the only solution for this question is the link(http://blog.gorges.us/2010/06/android-two-dimensional-scrollview). However this link is no longer active. Please help me.

Gopi
  • 689
  • 1
  • 8
  • 17
  • Enable Horizontal and vertical scrolling for ScrollView – Piyush Feb 19 '14 at 13:05
  • Check the accepted answer at [how-can-i-make-my-layout-scroll-both-horizontally-and-vertically](http://stackoverflow.com/questions/1399605/how-can-i-make-my-layout-scroll-both-horizontally-and-vertically). – Aduait Pokhriyal Feb 19 '14 at 13:06

1 Answers1

0

Try this code, it may help you..

    ScrollView scrollView = new ScrollView(this);
    HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
    LinearLayout linearLayout = new LinearLayout(this);

    horizontalScrollView.addView(linearLayout);

    scrollView.addView(horizontalScrollView);

    setContentView(scrollView);
Anil kumar
  • 1,534
  • 3
  • 14
  • 20
  • Mr.Anil Kumar It is working fine but by default layout is moving to complete right side, Even If I try to enter any input the same problem. – Gopi Feb 19 '14 at 13:32
  • check the orientations properly, some where it might be set to right – Anil kumar Feb 19 '14 at 13:34
  • This method doestn't provide a user friendly experience. I need a better idea for a better user experience – Gopi Feb 27 '14 at 18:56