1.Androidå¦ä½å¨java代ç ä¸è®¾ç½®margin
2.安卓编程 如何在Java代码里设置button的margin(外边距)?
Androidå¦ä½å¨java代ç ä¸è®¾ç½®margin
é¦å å®ä¹ä¸ªLayoutParamsï¼ç¶åå¨è®¾ç½®marginï¼å¨æè¿ä¸ªLayoutParams设置ç»æ§ä»¶ï¼å¦ä¸ï¼
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(,,,);//4个åæ°æ顺åºåå«æ¯å·¦ä¸å³ä¸
mView.setLayoutParams(layoutParams);
安卓编程 如何在Java代码里设置button的margin(外边距)?
1、获取按钮的27源码网LayoutParamsLinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)button.getLayoutParams();2、在LayoutParams中设置margin
layoutParams.setMargins(,javavalue注解源码,,5);//4个参数按顺序分别是左上右下3、把这个LayoutParams设置给按钮
button.setLayoutParams(layoutParams); //mView是cps指标源码控件