我们在主活动中动态创建了一个表,但是我们需要使表可滚动。在XML中,我只是将表格布局放在Scroll布局中。有没有办法通过活动动态地做到这一点?
答案 0 :(得分:1)
当然,您可以像以下一样以编程方式将整个布局放在ScrollView中:
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.mylayout, null);
ScrollView scrollView = new ScrollView(this);
scrollView.addView(view);
setContentView(scrollView);