android linearlayout 间隔
引用:http://www.eoeandroid.com/thread-100954-1-1.html
LinearLayout layoutView = new LinearLayout(context); LinearLayout.LayoutParams tabLayPar = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutView.setLayoutParams(tabLayPar); for循环加两个按钮{ Button button = new Button(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); layoutParams.weight = 1; layoutParams.leftMargin = 8; layoutParams.rightMargin = 8; button.setLayoutParams(layoutParams); layoutView.addView(button) ; } |
对里面的元素设置属性