Kev*_*vin 2 android button scrollview
我想实现这个功能:动态添加多个按钮到scrollview,如果scrollview超过一定高度,它会自动diplay滚动条.
你能给我一些建议吗?
检查以下代码段:
// Find the ScrollView
ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView1);
// Create a LinearLayout element
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
// Add Buttons
Button button = new Button(this);
button.setText("Some text");
linearLayout.addView(button);
// Add the LinearLayout element to the ScrollView
scrollView.addView(linearLayout);
Run Code Online (Sandbox Code Playgroud)
引用自我如何动态地向使用XML创建的视图添加元素.
| 归档时间: |
|
| 查看次数: |
11930 次 |
| 最近记录: |