對於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