我必须在android中水平添加两个相对的布局。我知道我必须使用addRule概念。但是我没有正确的链接来实现这一点。有人可以为我提供一些关于android中addRule的好教程以及解决方案这个问题。谢谢![可以看出,两个相对布局应该在一个父布局中。以下是我的代码:
//Layout on which my parentrelativelayout should be added
LinearaLayout ll=(LinearLayout)findViewbyId(R.id.ll);
RelativeLayout parentrelativelayout=new RelativeLayout(mContext);
parentrelativelayout.setId(1);
parentrelativelayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
parentrelativelayout.setBackgroundColor(Color.BLACK);
RelativeLayout rl_relativelayout1 = new RelativeLayout(mContext);
rl_relativelayout1.setId(2);
rl_relativelayout1.setLayoutParams(new LayoutParams(800,LayoutParams.WRAP_CONTENT));
rl_relativelayout1.setBackgroundResource(R.drawable.voucher_row);
RelativeLayout rl_relativelayout2=new RelativeLayout(mContext);
rl_relativelayout2.setId(3);
rl_relativelayout2.setBackgroundResource(R.drawable.grab_voucher);
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
我需要在 android 中以编程方式实现这一点。] 1