对于Java文件,你可以像下面先创建该XML文件,并设置在内容视图
,比
LinearLayout layout=new LinearLayout(this);
,而不是这一行
RelativeLayout linearMain = (LinearLayout) findViewById(R.id.RelativeLayout02);
和比在此添加您的看法
linearMain.addView(button);
像上面一行添加您的意见。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/RelativeLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
..............
your views
</RelativeLayout>
</ScrollView>
在XML中进行滚动查看。然后将运行时其他视图添加到它。 – 2012-07-13 11:38:11
@ answer88发布您的xml文件。 – 2012-07-13 11:40:30
我想使它在Java文件中。 – answer88 2012-07-13 11:40:36