标签:
1、定义LayoutParams
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);//定义一个LayoutParams
2、在LayoutParams中设置marginLeft
layoutParams.setMargins(20,0,0,0);//4个参数按顺序分别是左上右下
3、把这个LayoutParams设置给控件
mView.setLayoutParams(layoutParams); //mView是控件
Android 如何在Java代码中手动设置控件的marginleft
标签:
原文地址:http://www.cnblogs.com/zhujiabin/p/5740087.html