2012-06-05 31 views
0

我在android中以編程方式顯示,我需要水平和垂直滾動視圖。已垂直工作,但仍不能水平工作。ScrollView水平在UI編程Android

這裏的代碼:

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); 

請幫我使其水平工作。

三江源:)

+0

看看這個問題:http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizo​​ntal-in-android – Viking

回答

2

嘗試HorizontalScrollView如果你想水平滾動。儘管如此,你不能同時進行橫向和縱向的操作,在這種情況下,你可能不得不寫一個自定義視圖。

+0

你能解釋一下有關costum查看更多細節? –

+0

http://developer.android.com/guide/topics/ui/custom-components.html – MrJre

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);