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-11-27 04:48
2024-11-27 04:45
2024-11-27 04:15
2024-11-27 03:29
2024-11-27 03:21
2024-11-27 03:15