例如:
<ImageButton android:layout_marginTop="2dip"
android:id="@+id/account_option" android:layout_width="20px"
android:layout_height="20px" android:focusable="true"
android:src="@drawable/accountoptionbutton"
android:layout_alignParentRight="true" android:layout_marginRight="25px" />

----------------------------------------------------------------------------------

RelativeLayout rl = new RelativeLayout(this);
MarginLayoutParams mp = new MarginLayoutParams(20,20); //item的宽高
mp.setMargins(0, 0, 25, 0);//分别是margin_top那四个属性
LayoutParams lp = new LayoutParams(mp);
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

Button bt = new Button(this);
bt.setLayoutParams(lp);
rl.addView(bt);

PS: From eoeandroid, good job!

更多相关文章

  1. Android(安卓)xml解析实例详解
  2. Android(安卓)打开Activity后,不显示键盘
  3. 如何去掉ListView底部的ListDivider
  4. Android(安卓)windowSoftInputMode属性解析
  5. windowSoftInputMode属性设置值
  6. 使用ListView应该注意的地方
  7. Android(安卓)Animation动画(Frame-By-Frame Animations 、Tween
  8. activity的android:name 设置问题
  9. Android系统属性SystemProperties.set/get详解

随机推荐

  1. Android获取IMEI号
  2. android中隐藏以及显示软键盘代码
  3. Android开发网上的一些重要知识点
  4. Android 手势识别中的两个默认实现Simple
  5. android 字符串转json
  6. android opengl es 混合效果
  7. android studio 各种设置以及常见问题
  8. Android获取GPS进行定位的工具类
  9. Android多次加载bitmap后,提示内存溢出。
  10. Android集成百度地图SDK步骤