动态布局:只涉及相对布局和线性布局
先看一个例子
import android.app.Activity;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
public class DynamicLayout extends Activity {
protected void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layout=new LinearLayout(this);
EditText text=new EditText(this);
EditText text1=new EditText(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(text,0);
RelativeLayout realativeLayout=new RelativeLayout(this);
LayoutParams params=new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
Button btn1=new Button(this);
btn1.setLayoutPar