我正在以编程方式在android中进行显示,我需要水平和垂直方向的scrollview。已垂直工作,但仍不能横向工作。
这里是代码:
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 :(得分:2)
如果您想要水平滚动,请尝试HorizontalScrollView。你不能同时做横向和纵向两种情况,在这种情况下你可能不得不写一个自定义视图。
答案 1 :(得分: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);