当前位置: 代码迷 >> Android >> RelativeLayout边界布局有关问题
  详细解决方案

RelativeLayout边界布局有关问题

热度:28   发布时间:2016-05-01 20:58:40.0
RelativeLayout边界布局问题
这么一段代码
RelativeLayout lyUser=new RelativeLayout(this);
lyUser.setId(layUserID);
RelativeLayout.LayoutParams margin = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
margin.setMargins(15, 62, 15, 0);
lyUser.setLayoutParams(margin);

运行后Margin边界没反应

------解决方案--------------------
RelativeLayout.LayoutParams margin = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
margin.leftMargin = x;
margin.topMargin = y;
  相关解决方案