android ScrollView--Linearlayout可以上下拖动

动态添加:
[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只能是一个总的控件或者一个子控件,如果直接添加两个子控件会报错。

posted on 2014-01-14 16:14  三少爷的剑123  阅读(794)  评论(0编辑  收藏  举报

导航