从网上找的一个信息,在此记录一下

RelativeLayout insertLayout = (RelativeLayout)view1.findViewBy(R..screen);//screen是一个RelativeLayout 布局的

ImageView imgApple2 = new ImageView(MainActivity.this);
				        imgApple2.setBackgroundColor(Color.parseColor("#ffb6b4"));

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(100, 100);
        layoutParams.topMargin=8;
        layoutParams.leftMargin=8;
        layoutParams.rightMargin=8;
        layoutParams.bottomMargin=8;

insertLayout.addView(imgApple2,layoutParams);


//布局文件

<RelativeLayout

            android:id="@+id/layout_order_menu_bottom_line"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:gravity="bottom" >


 </RelativeLayout>