由于某种原因,我创建的布局的位置(边距)未设置。布局显示在 x=0 和 y=0 处。我究竟做错了什么?
smallPopup = new LinearLayout(this);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
p.setMargins(100, 100, 10, 10);
smallPopup.setLayoutParams(p);
smallPopup.setGravity(Gravity.CENTER_VERTICAL);
smallPopup.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
smallPopup.setBackgroundResource(R.drawable.map_small_popup_overlay);
smallPopup.setPadding(20, 10, 20, 10);
map.addView(smallPopup, p);