我使用RelativeLayout
放置視圖使用LayoutParams
並設置頂部(y座標)和左邊距(x座標)。我如何確保當我使用絕對位置放置視圖時,它們之間沒有任何重疊?我在某些地方遇到了重疊問題,現在唯一的工作就是擴大y值。如何確保視圖不會重疊放置在相對佈局
這裏是我的代碼放置的觀點:
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.leftMargin = x;
lp.topMargin = y;
那麼一旦我創建視圖我在正確的位置放置在佈局:
if(field.getType().equalsIgnoreCase("label"))
{
CSLabel label = (CSLabel) field;
TextView tv = new TextView(this);
tv.setText(Html.fromHtml(label.getText()));
rscroll.addView(tv, lp);
}
這裏是什麼,雖然發生的圖片有時:
文本在這種情況下,視圖和radiogroup是重疊的。有沒有什麼辦法來解決重疊編程?謝謝。