我有 relativelayout 作为容器,在那里我设置了文本和图像,接下来我 addView() 这个 relativelayout 两次到一个线性布局,一切都很好,但我不能将它们总是粘在一起的两个 relativelayout 分开,这里是代码:
线性布局
layout = new LinearLayout(context);
LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
ll.setMargins(5, 5, 5, 5);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setPadding(5, 5, 5, 5);
layout.setLayoutParams(ll);
layout.setId(i);
layout.addView(m1.box);
layout.addView(m2.box);
其中 m1 和 m2 是:RelativeLayout:
box = new RelativeLayout(context);
RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
rl.setMargins(5, 5, 5, 5);
rl.width = 125;
rl.height = 125;
box.setId(i);
box.setPadding(5, 5, 5, 5);
box.setBackgroundColor(color1);
box.setLayoutParams(rl);
//add some text and image
如何区分m1和m2?现在它们看起来像 OO 我需要添加空间 O_O。