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、获取按钮的轻量化源码LayoutParamsLinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)button.getLayoutParams();2、在LayoutParams中设置margin
layoutParams.setMargins(,导航源码整站,,5);//4个参数按顺序分别是左上右下3、把这个LayoutParams设置给按钮
button.setLayoutParams(layoutParams); //mView是策略模式源码控件2024-12-22 10:29
2024-12-22 10:06
2024-12-22 09:19
2024-12-22 09:14
2024-12-22 08:45
2024-12-22 08:42