【发布时间】:2014-03-27 10:00:16
【问题描述】:
我正在尝试在滚动视图中添加一个文本视图,然后以编程方式将此滚动视图添加到相对布局,但它只是显示空视图,即使只将文本视图添加到相对布局它的工作。
TextView aboutTextView = new TextView(this);
aboutTextView.setText(R.string.aboutText);
aboutTextView.setId(5);
aboutTextView.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
ScrollView scroll = new ScrollView(this);
scroll.setPadding(R.dimen.scroll_padding, R.dimen.scroll_padding,
R.dimen.scroll_padding, R.dimen.scroll_padding);
scroll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
scroll.addView(aboutTextView);
RelativeLayout fragmentContainer = (RelativeLayout) findViewById(R.id.fragmentContainer);
fragmentContainer.addView(scroll);
【问题讨论】:
标签: android android-relativelayout textview android-scrollview