1、layout_toRightOf="@id/imga"//根据id找到相对位置 如:below toRightOf
2、Src中通过代RelativeLayout.LayoutParams码相对布局
RelativeLayout rl = (RelativeLayout) super.findViewById(R.id.mylayout); // 找到布局管理器
RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT); // 定义参数 长度 高度
param.addRule(RelativeLayout.BELOW, R.id.mybut); // 新的组件放在mybut组件之下
param.addRule(RelativeLayout.RIGHT_OF, R.id.imga); // 放在第一张图片的右边
EditText text = new EditText(this); // 输入文本
rl.addView(text, param); // 是向一个布局管理器之中增加组件
3、对齐
android:layout_alignParentTop="true"
android:layout_alignTop="@id/txt"
adnroid:layout_marginLeft="10px"
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。