Android 中动态添加控件,并设置居中和Margin:
其中DisplayUtil.dip2px()是为了适配。

   SimpleDraweeView image = new SimpleDraweeView(getContext());   LayoutParams param = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);   param.height = DisplayUtil.dip2px(getContext(), 140);   param.width = DisplayUtil.dip2px(getContext(), 140);   param.setMargins(0, DisplayUtil.dip2px(getContext(), 200), 0, 0); // Margin   param.addRule(RelativeLayout.CENTER_HORIZONTAL);//水平居中   addView(image, param);

更多相关文章

  1. Android Studio学习:简单控件:Button控件的点击、长按函数重写
  2. 水平布局linerlayout
  3. android的一些自定义控件
  4. android : 控件在代码中设置属性-setWidth(int pixels)或setHeig
  5. android之4.0控件switch自定义开关背景图片和控制宽度
  6. 控件布局_TableLayout
  7. Android 日历方式显示的日期选择组件(日历控件之一)
  8. 控件的圆角

随机推荐

  1. Linux格式化报错mkfs.ext4: undefined sy
  2. 【linux】实战扩展swap分区
  3. Linux运维方向文章汇总
  4. 【linux】循序渐进学运维-ls
  5. 【linux】RAID磁盘阵列介绍
  6. 【Linux】循序渐进学运维系列文章前言
  7. 我在Python的艳阳里,大雪纷飞
  8. 【Linux】循序渐进学运维-学习方法篇
  9. Server2012 R2 Powershell4升级到Powersh
  10. 【linux】循序渐进学运维-echo