代码实现Layout android:layout_alignParentRight
16lz
2021-12-04
例如:
<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!
更多相关文章
- Android(安卓)xml解析实例详解
- Android(安卓)打开Activity后,不显示键盘
- 如何去掉ListView底部的ListDivider
- Android(安卓)windowSoftInputMode属性解析
- windowSoftInputMode属性设置值
- 使用ListView应该注意的地方
- Android(安卓)Animation动画(Frame-By-Frame Animations 、Tween
- activity的android:name 设置问题
- Android系统属性SystemProperties.set/get详解