-1
4個角落,我想4次增加4個角編程屏幕,添加4次以編程方式使用ALIGN_PARENT
但由於需要它不工作。請幫助我。
View[] TchBoxAryVar = new View[4];
int LyoRulAryVar[] = {RelativeLayout.ALIGN_PARENT_TOP,
RelativeLayout.ALIGN_PARENT_TOP |
RelativeLayout.ALIGN_PARENT_RIGHT,
RelativeLayout.ALIGN_PARENT_BOTTOM,
RelativeLayout.ALIGN_PARENT_BOTTOM |
RelativeLayout.ALIGN_PARENT_RIGHT};
int ClrAryVar[] = {Color.RED, Color.GREEN, Color.GRAY, Color.MAGENTA};
for(int IdxVal = 0; IdxVal < TchBoxAryVar.length; IdxVal++)
{
Log.d("TAG", "onCreate: " + IdxVal);
TchBoxAryVar[IdxVal] = new View(this);
RelativeLayout.LayoutParams LyoRulVar = new RelativeLayout.LayoutParams(200, 200);
LyoRulVar.addRule(LyoRulAryVar[IdxVal]);
TchBoxAryVar[IdxVal].setLayoutParams(LyoRulVar);
TchBoxAryVar[IdxVal].setBackgroundColor(ClrAryVar[IdxVal]);
MainViewVav.addView(TchBoxAryVar[IdxVal]);
}
感謝您支持我的工作答案... – AlexTa