动态添加:
[java] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>    
  2. <ScrollView    
  3.     xmlns:android="http://schemas.android.com/apk/res/android"    
  4.     android:layout_width="fill_parent"    
  5.     android:layout_height="fill_parent"    
  6.     android:scrollbars="vertical"    
  7.     android:fadingEdge="vertical">    
  8.     <LinearLayout    
  9.         android:layout_width="fill_parent"    
  10.         android:layout_height="fill_parent"    
  11.         android:orientation="vertical"    
  12.         >    
  13.     </LinearLayout>    
  14. </ScrollView>    



动态代码上:

scrollView=new ScrollView(getApplicationContext());
scrollView.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));
scrollView.setScrollbarFadingEnabled(true);

scrollview.addView(XXXX);

值得一提的是XXX只能是一个总的控件或者一个子控件,如果直接添加两个子控件会报错。

相关文章:

  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-05-20
  • 2022-01-21
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案