动态添加:
[java] view
plaincopy
plaincopy
- <?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"
- android:scrollbars="vertical"
- android:fadingEdge="vertical">
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- >
- </LinearLayout>
- </ScrollView>
动态代码上:
scrollView=new ScrollView(getApplicationContext());
scrollView.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));
scrollView.setScrollbarFadingEnabled(true);
scrollview.addView(XXXX);
值得一提的是XXX只能是一个总的控件或者一个子控件,如果直接添加两个子控件会报错。