Android 如何在特定的相对布局上布置图形对象?

Android 如何在特定的相对布局上布置图形对象?,android,android-layout,imageview,android-relativelayout,android-drawable,Android,Android Layout,Imageview,Android Relativelayout,Android Drawable,我有一个框架布局,并向其中添加了RelativeLayout。我的相对布局中有一些按钮。我可以用以下代码更改他们与relativeLayout相关的位置: ibrllp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); ibrllp.topMargin=0; ibrllp.leftMargin=0; ib = new ImageButton(this); ib.setIm

我有一个框架布局,并向其中添加了RelativeLayout。我的相对布局中有一些按钮。我可以用以下代码更改他们与relativeLayout相关的位置:

ibrllp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ibrllp.topMargin=0;
ibrllp.leftMargin=0;
ib = new ImageButton(this);
ib.setImageResource(R.drawable.image);
ib.setLayoutParams(ibrllp);
rl.addView(ib);
我想添加一个imageView并在这个相对图上画一些线。使用此代码:

rl= (RelativeLayout) findViewById(R.id.relativeLayout2);
fllp =new FrameLayout.LayoutParams(600,400);
fllp.gravity=Gravity.CENTER;
rl.setLayoutParams(fllp);

ibllpImageView= new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
ibllpImageView.topMargin=100;
ibllpImageView.leftMargin=100;

drawingImageView = new ImageView(this);
bitmap = Bitmap.createBitmap((int) getWindowManager()
  .getDefaultDisplay().getWidth(), (int) getWindowManager()
  .getDefaultDisplay().getHeight(), Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitmap);
drawingImageView.setImageBitmap(bitmap);
paint = new Paint();
paint.setStrokeWidth(10);
paint.setColor(Color.RED);
drawingImageView.setLayoutParams(ibllpImageView);

rl.addView(drawingImageView); 
canvas.drawLine(0, 0 , 400, 400, paint);      
它画了一条线,但位置不对。我希望能够设置与相对长度相关的直线起点的坐标。就像纽扣一样。。。但是我不能。。。 这段代码是我的Xml:

   <FrameLayout
    android:id="@+id/frameLayout4Chob"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/purple"
    android:layout_weight="0.43" >
    <RelativeLayout
        android:id="@+id/relativeLayout4Chob"
        android:layout_width="match_parent"
        android:layout_height="414dp"
        android:layout_gravity="center"
        android:background="@drawable/blue" >         
    </RelativeLayout>
  </FrameLayout>
问题在哪里