android java写布局LinearLayou.LayoutParams参数

来源:互联网 发布:中频治疗仪 知乎 编辑:程序博客网 时间:2024/06/06 09:56

private LinearLayout layout;//创建一个布局

layout = mLayout = (LinearLayout) findViewById(R.id.layout);

TextView text = new TextView(MainActivity.this);

text.setText("往layout中添加TextView");

//设置LinearLayout的参数,(宽,高)

LinearLayout.LayoutParams p = 

new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);

layout.addView(text,p);//往layout中添加TextView

0 0
原创粉丝点击