zoukankan      html  css  js  c++  java
  • 红色childview2位于白色view左边20dp

    @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);
    }
    ---------------------

  • 相关阅读:
    css问题
    前端性能优化整理
    算法之排序
    浅谈webpack优化
    js设计模式
    事件模型
    浏览器缓存
    ucGUI 12864 从打点起
    ucGUI例程收藏
    Qt 自动搜索串口号列表
  • 原文地址:https://www.cnblogs.com/hyhy904/p/11379393.html
Copyright © 2011-2022 走看看