码迷,mamicode.com
首页 > 其他好文 > 详细

红色childview2位于白色view左边20dp

时间:2019-08-19 20:54:44      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:cti   bundle   void   super   etc   create   save   ddr   p2p   

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
View childView = findViewById(R.id.child1);
RelativeLayout parent = findViewById(R.id.parent);
RelativeLayout.LayoutParams lps = (RelativeLayout.LayoutParams) childView.getLayoutParams();
lps.rightMargin = dip2px(this, 20.0f);
lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

View childView2 = findViewById(R.id.child2);
RelativeLayout.LayoutParams lps2 = (RelativeLayout.LayoutParams) childView2.getLayoutParams();
//lps2.addRule(RelativeLayout.BELOW,R.id.child1);
lps2.rightMargin = dip2px(this, 20.0f);
lps2.addRule(RelativeLayout.LEFT_OF, R.id.child1);
}
---------------------

红色childview2位于白色view左边20dp

标签:cti   bundle   void   super   etc   create   save   ddr   p2p   

原文地址:https://www.cnblogs.com/hyhy904/p/11379393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!